Repository navigation
fix(typing): make full-tree mypy pass for the scheduled pre-commit run - #46634
Open
sadpandajoe wants to merge 1 commit into
Open
sadpandajoe wants to merge 1 commit into
sadpandajoe wants to merge 1 commit into
Conversation
The scheduled pre-commit run checks every file, and its mypy (main) hook reported 7 errors in 6 files that per-PR runs never see. With follow_imports = "skip" for superset_core.*, a changed-files run treats superset-core types as Any; the full-tree run passes superset-core's sources explicitly and resolves the real types. - superset-core declares SqlaTable's id as a plain int, so SqlaTable.id.in_() / model.id.in_() are false positives in the full tree: ignore them with unused-ignore so scoped runs stay green (same pattern as superset/daos/dashboard.py and superset/daos/chart.py). - The mypy hook env has no pytest, so pytest.fail is not NoReturn there: ignore the missing return on the must_not_execute stub. - Give the expected filter set in mapper_test an explicit set[FilterExpression] type, and narrow the cache_or_filters_test parameter to the str / frozenset[str] values it is parametrized with. Introduced by #46153, #46377, #46479 and #46549. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46634 +/- ##
==========================================
- Coverage 86.09% 86.09% -0.01%
==========================================
Files 3140 3140
Lines 219210 219210
Branches 51975 51975
==========================================
- Hits 188736 188734 -2
- Misses 27047 27048 +1
- Partials 3427 3428 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
The scheduled
pre-commit checksrun, which checks all files, has failed since 2026-11-21. Itsmypy (main)hook reports 7 errors in 6 files. Every PR passed its own pre-commit run because those runs check only the files the PR changed, and mypy resolves types differently in that case.Root cause:
pyproject.tomlsetsfollow_imports = "skip"forsuperset_core.*. When only changed files are checked, superset-core types (Dataset,Filter,OrFilter,SemanticResult, …) resolve toAny, so nothing is flagged. The full-tree run passes superset-core's sources explicitly and gets the real types. Thepyproject.tomlcomment block "The mirror case" already documents this. Each of the 6 files passes mypy when checked alone and fails only in the full tree. The errors came in with:superset/daos/dashboard.py:838.SqlaTableinheritsid: intfrom superset-core'sDataset, which comes first in its MRO, so mypy seesSqlaTable.id.in_()as an attribute onint.tests/unit_tests/semantic_layers/mapper_test.py:2040andtests/unit_tests/semantic_layers/cache_or_filters_test.py:118(2 errors).tests/unit_tests/versioning/test_archive_activity.py:411andtests/integration_tests/versioning/chart_archive_activity_tests.py:104. Sameintid problem through aDashboard | Slice | SqlaTablemodel union.superset-core/tests/semantic_layers/test_conformance.py:246. The hook environment has no pytest installed, sopytest.failis notNoReturnthere.The fix is the smallest change at each site:
id.in_()false positives and themust_not_executestub get a# type: ignore[<code>,unused-ignore]. This is the pattern already used insuperset/daos/dashboard.pyandsuperset/daos/chart.py. Theunused-ignorecode stops changed-files runs, where the ignore isn't needed, from failing underwarn_unused_ignores. The stub keepspytest.fail: it runs insidepytest.raises(AssertionError), so raisingAssertionErrorinstead would let the test pass falsely. Annotating itNoReturngives a new[misc]error in the hook environment.mapper_test.pynow has an explicitset[FilterExpression]type. Thecache_or_filters_test.pyparameter is narrowed to thestr/frozenset[str]values it is parametrized with.pyproject.tomlis unchanged, and no runtime code paths change.TESTING INSTRUCTIONS
mypy (main)hook environment:pre-commit install-hooks.pre-commit run mypy --all-files. Before this change it reports "Found 7 errors in 6 files". After it, the hook passes.pre-commit run mypy.ADDITIONAL INFORMATION
🤖 Generated with Claude Code