Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Nightly full-repo pre-commit fails: mypy Filter|OrFilter narrowing gaps in semantic-layer tests

Closed Beginner friendly
#45,267 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@sadpandajoe is already working on this.

Since Oct 14, 2026.

  • #45268 by @sadpandajoe — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

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

ai:fix-master
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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/superset

All issues in apache/superset

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.