You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sadpandajoe (via GitHub)" <gi...@apache.org> on 2026/10/11 08:33:31 UTC

[PR] fix(semantic-layer): narrow ValidatedQueryObject.metrics to list[str] [superset]

sadpandajoe opened a new pull request, #45185:
URL: https://github.com/apache/superset/pull/45185

   ### SUMMARY
   The nightly full-repo mypy run (`pre-commit run --all-files`) flags `superset/semantic_layers/mapper.py:402`:
   `Invalid index type "AdhocMetric | str" for "dict[str, Metric]"; expected type "str"`. This is a name collision,
   not a logic bug: `QueryObject.metrics` (superset/common/query_object.py:109) is typed `list[Metric] | None` using
   the unrelated `superset.superset_typing.Metric` alias (`AdhocMetric | str`), while `all_metrics` at mapper.py:393
   is keyed by the semantic layer's own `Metric` dataclass from `superset_core.semantic_layers.types`. mypy only
   surfaces this when `superset-core` is on the mypy command line directly (the nightly job), since
   `superset_core.*` otherwise runs with `follow_imports = "skip"`.
   
   `ValidatedQueryObject` already narrows `filter`, `series_columns`, and `series_limit_metric` away from their
   ambiguous base types for exactly this reason, but missed `metrics`. At runtime this was never an actual risk:
   `_validate_metrics` (mapper.py:1195) already raises `ValueError` if any `query_object.metrics` entry isn't a
   plain `str`, and `validate_query_object`'s `TypeGuard[ValidatedQueryObject]` only returns `True` after that
   check passes — so by the time `_map_query_object` runs, `query_object.metrics` is guaranteed `list[str] | None`.
   This change just makes the static type match that existing runtime guarantee.
   
   Fixes #45184
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A — static type-only fix, no UI surface.
   
   ### TESTING INSTRUCTIONS
   1. `pip install -r requirements/development.txt` (or an equivalent env with `mypy` + `apache-superset-core` installed editable)
   2. Run mypy with superset-core on the command line, matching the nightly job:
      `mypy --config-file pyproject.toml superset/semantic_layers/mapper.py $(find superset-core/src -name "*.py")`
   3. Confirm no `mapper.py:402` error and no new `unused-ignore` warning
   4. `pytest tests/unit_tests/semantic_layers/mapper_test.py` — all 203 tests pass unchanged
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #45184
   - [ ] 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
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic-layer): narrow ValidatedQueryObject.metrics to list[str] [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe merged PR #45185:
URL: https://github.com/apache/superset/pull/45185


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic-layer): narrow ValidatedQueryObject.metrics to list[str] [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #45185:
URL: https://github.com/apache/superset/pull/45185#issuecomment-6107205177

   ## CodeAnt PR Risk: Low Risk
   
   - The PR appears safe to merge; the visible change only declares an optional metrics field on ValidatedQueryObject.
   
   **Assessed commit:** `ec55aaf03651`


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic-layer): narrow ValidatedQueryObject.metrics to list[str] [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #45185:
URL: https://github.com/apache/superset/pull/45185#issuecomment-6107271264

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/45185?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 65.29%. Comparing base ([`e229ea4`](https://app.codecov.io/gh/apache/superset/commit/e229ea4a543546b94bc3e751f611109d111cc8db?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ec55aaf`](https://app.codecov.io/gh/apache/superset/commit/ec55aaf03651544ae5cdb7872d6cb52d09f0bdf1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (e229ea4) and HEAD (ec55aaf). Click for more details.
   > 
   > <details><summary>HEAD has 4 uploads less than BASE</summary>
   >
   >| Flag | BASE (e229ea4) | HEAD (ec55aaf) |
   >|------|------|------|
   >|python|7|3|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #45185       +/-   ##
   ===========================================
   - Coverage   82.90%   65.29%   -17.61%     
   ===========================================
     Files        3018     3018               
     Lines      193288   193289        +1     
     Branches    45018    45018               
   ===========================================
   - Hits       160236   126213    -34023     
   - Misses      30014    64255    +34241     
   + Partials     3038     2821      -217     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `35.24% <100.00%> (+<0.01%)` | :arrow_up: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.07% <100.00%> (+<0.01%)` | :arrow_up: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.61% <100.00%> (-32.97%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.49% <100.00%> (+<0.01%)` | :arrow_up: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/45185/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/45185?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org