Skip to content

MyPy support in OSS#990

Merged
haritamar merged 21 commits into
masterfrom
ele-1267-add-mypy-to-the-oss
Jul 13, 2023
Merged

MyPy support in OSS#990
haritamar merged 21 commits into
masterfrom
ele-1267-add-mypy-to-the-oss

Conversation

@haritamar
Copy link
Copy Markdown
Collaborator

No description provided.

@linear
Copy link
Copy Markdown

linear Bot commented Jul 12, 2023

@github-actions
Copy link
Copy Markdown
Contributor

👋 @haritamar
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

Comment thread setup.py
model_specific_channel_config = model_meta_data.get(CHANNEL_KEY)

model_specific_channel_config = alert.model_meta.get(CHANNEL_KEY)
if model_specific_channel_config:
Copy link
Copy Markdown
Collaborator Author

@haritamar haritamar Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit unsure if I'm missing anything here, but it does look like model_meta is always parsed in __init__ and is already a dict at this point
The only place I had to fix is the mock data in the tests

Comment thread elementary/monitor/api/totals_schema.py
Comment thread elementary/clients/dbt/slim_dbt_runner.py
@haritamar haritamar force-pushed the ele-1267-add-mypy-to-the-oss branch from ba76ae4 to 7c2b588 Compare July 13, 2023 10:07
Comment thread .github/workflows/run-precommit.yml Outdated
Comment thread .pre-commit-config.yaml
Comment thread elementary/cli/upgrade.py
Comment thread elementary/clients/dbt/slim_dbt_runner.py Outdated
quiet: bool = False,
**kwargs,
) -> list:
if self.profiles_dir is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it use dbt's default in this case?
I think this is supported.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall this was broken in dbt 1.5
The profiles dir is parsed externally, so the config is already assumed to contain it.
I already changed back then the __init__ function to make profiles_dir mandatory (only for the slim runner), but couldn't convince mypy here that it can't be None so added this check

Comment thread elementary/monitor/api/tests/tests.py Outdated
Comment thread elementary/monitor/api/tests/tests.py Outdated
sample_data = test_result_db_row.sample_data if not disable_samples else None
if test_result_db_row.test_type == "dbt_test":
if sample_data is not None and not isinstance(sample_data, list):
# Sanity check, shouldn't happen
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really like this.
If it shouldn't happen there shouldn't be a check for it.
I think it means we're doing something wrong.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy has no way of knowing that specifically for dbt_test it must be a list, and for dimension anomalies it must be a dict.
So this is a way to narrow down the type
Do you think cast is better in such cases?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing to cast

Comment thread elementary/monitor/api/tests/tests.py Outdated
Comment thread elementary/monitor/api/tests/tests.py Outdated
Comment thread elementary/tracking/tracking_interface.py Outdated
@haritamar haritamar merged commit 80f3bbb into master Jul 13, 2023
@haritamar haritamar deleted the ele-1267-add-mypy-to-the-oss branch July 13, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants