Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] mypy 1.9 + begin wider tests type-checking #9678

Merged
merged 21 commits into from Apr 1, 2024

Conversation

Kilo59
Copy link
Member

@Kilo59 Kilo59 commented Mar 29, 2024

This PR does a couple different type-checking related things.

  1. Update mypy to 1.9 and removes a couple of now unused type: ignore comments because of better type inference.
  2. Begin to type-check some more of our tests. Previously, the only tests being checked were tests/datasource/fluent. In particular, I tried to include tests under active development for the v1 release. Also new test files should now be type-checked by default unless they are excluded.
  3. Update test_packaging to make it easier to update pins/versions for things like ruff, & mypy and other development only packages that SHOULD be pinned.

I'm happy to split this PR up if desired.

Copy link

netlify bot commented Mar 29, 2024

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit 0e5d8f1
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/66079769a2adb70008334a50

@Kilo59 Kilo59 changed the title mypy 1.9 [MAINTENANCE] mypy 1.9 Mar 29, 2024
@Kilo59 Kilo59 self-assigned this Mar 30, 2024
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.55%. Comparing base (200c968) to head (0e5d8f1).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #9678   +/-   ##
========================================
  Coverage    82.55%   82.55%           
========================================
  Files          511      511           
  Lines        46381    46381           
========================================
  Hits         38288    38288           
  Misses        8093     8093           
Flag Coverage Δ
3.10 64.60% <ø> (ø)
3.10 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds ?
3.10 aws_deps ?
3.10 big ?
3.10 databricks ?
3.10 filesystem ?
3.10 mssql ?
3.10 mysql ?
3.10 postgresql ?
3.10 spark ?
3.10 trino ?
3.11 64.60% <ø> (ø)
3.11 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds 53.98% <ø> (ø)
3.11 aws_deps 48.99% <ø> (ø)
3.11 big 64.00% <ø> (ø)
3.11 databricks 48.21% <ø> (ø)
3.11 filesystem 63.78% <ø> (ø)
3.11 mssql 47.43% <ø> (ø)
3.11 mysql 47.48% <ø> (ø)
3.11 postgresql 54.27% <ø> (ø)
3.11 snowflake 48.74% <ø> (+<0.01%) ⬆️
3.11 spark 60.66% <ø> (ø)
3.11 trino 53.90% <ø> (ø)
3.8 64.61% <ø> (ø)
3.8 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds 53.98% <ø> (ø)
3.8 aws_deps 49.00% <ø> (ø)
3.8 big 64.00% <ø> (ø)
3.8 databricks 48.23% <ø> (ø)
3.8 filesystem 63.79% <ø> (-0.01%) ⬇️
3.8 mssql 47.41% <ø> (ø)
3.8 mysql 47.47% <ø> (ø)
3.8 postgresql 54.26% <ø> (ø)
3.8 snowflake 48.76% <ø> (+<0.01%) ⬆️
3.8 spark 60.62% <ø> (ø)
3.8 trino 53.89% <ø> (ø)
3.9 64.61% <ø> (ø)
3.9 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds ?
3.9 aws_deps ?
3.9 big ?
3.9 databricks ?
3.9 filesystem ?
3.9 mssql ?
3.9 mysql ?
3.9 postgresql ?
3.9 spark ?
3.9 trino ?
cloud 0.00% <ø> (ø)
docs-basic 54.50% <ø> (ø)
docs-creds-needed 55.07% <ø> (ø)
docs-spark 54.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


import pytest
import requirements as rp

IGNORE_PINS: Final[set[str]] = {"mypy", "ruff", "pytest"}
Copy link
Member Author

@Kilo59 Kilo59 Mar 30, 2024

Choose a reason for hiding this comment

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

It doesn't make sense to check some of these development only packages. These packages SHOULD be pinned, but these checks end up punishing pinning and make it very tedious and error-prone to update the versions/pins.

I've added this IGNORE_PINS constant so that the packaging step just ignores anything here.

I've also had it completely ignore the requirement-types package since most of those types are either stubs or packages that are pulled from other requirement files which are already checked here.

@Kilo59 Kilo59 changed the title [MAINTENANCE] mypy 1.9 [MAINTENANCE] mypy 1.9 + begin wider tests type-checking Mar 30, 2024
@Kilo59 Kilo59 marked this pull request as ready for review March 30, 2024 03:57
Comment on lines +126 to +127
'tests/actions/test_core_actions\.py',
'tests/checkpoint/test_checkpoint_result_format\.py',
Copy link
Member Author

@Kilo59 Kilo59 Apr 1, 2024

Choose a reason for hiding this comment

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

All these new exclude lines were incredibly tedious to add.
I should have just written a script to do it, but I decided I was already in too deep doing it manually. 😆

Copy link
Contributor

@tyler-hoffman tyler-hoffman left a comment

Choose a reason for hiding this comment

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

Left some small comments, but non-blocking. Thanks for doing this!

@@ -3355,7 +3351,7 @@ def empty_base_data_context_in_cloud_mode_custom_base_url(
) -> CloudDataContext:
project_path = tmp_path / "empty_data_context"
project_path.mkdir()
project_path = str(project_path)
project_path = str(project_path) # type: ignore[assignment]
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking since this isn't actively changing anything, but changing the type of project_path feels bad. I think the best solution here would be just to update line 3362 to be context_root_dir=str(project_path), since it looks like the string version is only used there.

Copy link
Member Author

@Kilo59 Kilo59 Apr 1, 2024

Choose a reason for hiding this comment

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

I agree.

I want to followup with a PR to actually fix the typing issues in conftest.py since it's a core file that almost every other test relies on.

I'm trying to get this one in quickly since new v1 related PR's that merge into develop will almost certainly require changes to the exclude list or the existing type-ignores.

@@ -7556,21 +7552,22 @@ def _multibatch_generic_csv_generator(
5: "category5",
6: "category6",
}
for batch_num in range(num_event_batches):
for batch_num in range(num_event_batches): # type: ignore[arg-type]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing reording the params and making the num_ params non-optional is a larger lift? Might be cleanest to just assert instance on them at the top of the method. But that's totally non-blocking.

@Kilo59 Kilo59 added this pull request to the merge queue Apr 1, 2024
Merged via the queue into develop with commit 2c880fc Apr 1, 2024
220 checks passed
@Kilo59 Kilo59 deleted the m/_/test_type-checking branch April 1, 2024 15:54
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.

None yet

2 participants