Skip to content

fix(typing): make full-tree mypy pass for the scheduled pre-commit run - #46634

Open
sadpandajoe wants to merge 1 commit into
masterfrom
ultraset-mypy-full-tree-type-errors-scheduled-pre-commit
Open

sadpandajoe wants to merge 1 commit into
masterfrom
ultraset-mypy-full-tree-type-errors-scheduled-pre-commit

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

SUMMARY

The scheduled pre-commit checks run, which checks all files, has failed since 2026-11-21. Its mypy (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.toml sets follow_imports = "skip" for superset_core.*. When only changed files are checked, superset-core types (Dataset, Filter, OrFilter, SemanticResult, …) resolve to Any, so nothing is flagged. The full-tree run passes superset-core's sources explicitly and gets the real types. The pyproject.toml comment 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:

The fix is the smallest change at each site:

  • The three id.in_() false positives and the must_not_execute stub get a # type: ignore[<code>,unused-ignore]. This is the pattern already used in superset/daos/dashboard.py and superset/daos/chart.py. The unused-ignore code stops changed-files runs, where the ignore isn't needed, from failing under warn_unused_ignores. The stub keeps pytest.fail: it runs inside pytest.raises(AssertionError), so raising AssertionError instead would let the test pass falsely. Annotating it NoReturn gives a new [misc] error in the hook environment.
  • The two semantic-layer tests had real annotation gaps. The expected filter set in mapper_test.py now has an explicit set[FilterExpression] type. The cache_or_filters_test.py parameter is narrowed to the str / frozenset[str] values it is parametrized with.

pyproject.toml is unchanged, and no runtime code paths change.

TESTING INSTRUCTIONS

  1. Install the mypy (main) hook environment: pre-commit install-hooks.
  2. Run pre-commit run mypy --all-files. Before this change it reports "Found 7 errors in 6 files". After it, the hook passes.
  3. Check that a changed-files run also passes: stage only the 6 files touched here and run pre-commit run mypy.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

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>
@sadpandajoe sadpandajoe added the ai:fix-master generated by AI to fix master branch label Nov 27, 2026
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 7db9b09e6ec3

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.09%. Comparing base (ad1abef) to head (7db9b09).

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     
Flag Coverage Δ
hive 33.68% <ø> (ø)
mysql 51.47% <ø> (ø)
postgres 51.49% <ø> (-0.01%) ⬇️
presto 35.37% <ø> (ø)
python 88.58% <ø> (-0.01%) ⬇️
sqlite 51.17% <ø> (ø)
unit 84.14% <ø> (-0.01%) ⬇️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:fix-master generated by AI to fix master branch size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant