sadpandajoe opened a new pull request, #45268: URL: https://github.com/apache/superset/pull/45268
### SUMMARY No specific introducing commit/PR was identified — git history shows no recent change to the touched test files or to `superset-core/src/superset_core/semantic_layers/types.py`; this is a long-standing mismatch that stays hidden in normal CI because `pyproject.toml` sets `follow_imports = "skip"` for `superset_core.*`. Only the nightly full-repo mypy run, which puts `superset-core` on mypy's command line, type-checks these call sites against the real `SemanticQuery.filters: set[Filter | OrFilter] | None` signature instead of treating the import loosely. Two test call sites hadn't adopted the `isinstance(..., OrFilter)` narrowing idiom product code already uses in `superset/semantic_layers/cache_policy.py`: `cache_policy_test.py`'s `_candidate` helper declared its `query_filters` parameter as the narrower `set[Filter] | None`, and `metric_filter_test.py` iterated `query.filters` without guarding against `None` or narrowing each element to `Filter` before reading `.column`. This PR widens the helper's parameter type to match `SemanticQuery.filters`, and adds the missing `None` guard plus `isinstance` narrowing. Neither fixture ever constructs an `OrFilter`, so there is no behavior change — only type annotations and narrowing. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF ### TESTING INSTRUCTIONS 1. Check out this branch. 2. In a venv with `pip install -r requirements/development.txt && pip install -e . -e ./superset-core` (plus `mypy==1.15.0` and the stub packages listed in `.pre-commit-config.yaml`'s `mypy (main)` hook). 3. Run `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` — 0 errors (previously 3: one at `cache_policy_test.py:78`, two at `metric_filter_test.py:248`). 4. Run `pytest tests/unit_tests/semantic_layers/cache_policy_test.py tests/unit_tests/semantic_layers/metric_filter_test.py` — 74 passed, unchanged from before. ### ADDITIONAL INFORMATION - [x] Has associated issue: Fixes #45267 - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] 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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
