Nightly full-repo pre-commit fails: mypy Filter|OrFilter narrowing gaps in semantic-layer tests
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start with the two test files named in the mypy output: tests/unit_tests/semantic_layers/cache_policy_test.py (the _candidate helper near line 71) and tests/unit_tests/semantic_layers/metric_filter_test.py (around line 248). Compare them with the product code in superset/semantic_layers/cache_policy.py, which already narrows with isinstance(filter_, OrFilter). Run the mypy command from the issue to reproduce the three errors. Done means that command reports no errors for these files and the unit tests in tests/unit_tests/semantic_layers still pass.
Written by the indexing model from the issue text.
Description
Problem
The nightly full-repo pre-commit run on master fails mypy with 3 errors in two semantic-layer test files: https://github.com/apache/superset/actions/runs/38521870062/job/115713188528 (commit 7f1bfaba4b2968e0818d6e08e79d34ecae0bd3f1, 2026-10-14).
tests/unit_tests/semantic_layers/cache_policy_test.py:78: error: Argument "filters" to "SemanticQuery" has incompatible type "set[Filter] | None"; expected "set[Filter | OrFilter] | None" [arg-type]
tests/unit_tests/semantic_layers/metric_filter_test.py:248: error: Item "OrFilter" of "Filter | OrFilter | Any" has no attribute "column" [union-attr]
tests/unit_tests/semantic_layers/metric_filter_test.py:248: error: Item "None" of "set[Filter | OrFilter] | None" has no attribute "__iter__" (not iterable) [union-attr]
Root cause
#45133 (fix(semantic-layer): preserve NULL selections in chart filters, f5404f7eae, merged 2026-10-13) widened SemanticQuery.filters to set[FilterExpression] | None where FilterExpression = Filter | OrFilter (superset-core/src/superset_core/semantic_layers/types.py), and updated 8 sibling semantic-layer test files to match but missed these two. cache_policy_test.py:71's _candidate helper still declares query_filters as the narrower set[Filter] | None (mypy sets are invariant). metric_filter_test.py:248 iterates query.filters with no None-guard or isinstance narrowing before reading .column, which OrFilter lacks. Product code (superset/semantic_layers/cache_policy.py:236) already uses isinstance(filter_, OrFilter); these two test files hadn't adopted it. Only visible when superset-core is on the mypy command line (pyproject.toml sets follow_imports = "skip" for superset_core.* normally), so only the nightly full-repo run surfaces it.
Steps to reproduce
With mypy 1.15.0 and superset-core installed editable:
mypy --check-untyped-defs --config-file pyproject.toml tests/unit_tests/semantic_layers/cache_policy_test.py tests/unit_tests/semantic_layers/metric_filter_test.py superset-core/src/superset_core/semantic_layers/types.py
(Found via automated investigation — Agor.)
- Dominant language
- Python
- Stars
- 75.3k
- Forks
- 18.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 641
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/superset
-
Chart and dashboard thumbnails ignore SUPERSET_APP_ROOTPossibly taken @greg-om claimed this 3 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
Bar chart: bars on a temporal x-axis shrink to hairlines when the time grain is finer than the data (7.0.0rc2)Possibly taken @Anikesh0001 claimed this 6 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/superset#45474 · 2 comments ·
Maintainers usually reply within 2 days
-
get_time_filter Jinja macro returns 500 when the chart has a custom SQL filterPossibly taken @SEPURI-SAI-KRISHNA claimed this 12 days ago. Open🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/superset#45269 · 1 comment ·
Maintainers usually reply within 2 days
-
flatten post-processing drops index columns when the index has several levelsPossibly taken @AliIbnBotir claimed this 12 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
RadioButtonControl calls onChange twice per selection (Radio.Group onChange plus a per-button onClick)Possibly taken @FrancescoCastaldi claimed this 23 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
yzhao062/awesome-auditable-ai#45 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
NVIDIA/flare-local-inference#90 ·
Maintainers usually reply within 1 day
-
area/streaming comp/gateway P2 platform/telegram type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#144897 ·
Maintainers usually reply within 1 day
-
request-theme
Difficulty 1/5 Under an hour Newbie friendliness 66/100
LizardByte/ThemerrDB#9575 ·
Maintainers usually reply within 1 day