sadpandajoe opened a new pull request, #44944:
URL: https://github.com/apache/superset/pull/44944
Fixes #44943
### SUMMARY
The nightly full-repo mypy sweep fails with two `[union-attr]` errors on
`Slice.uuid.in_()` in the chart importer (added by #43232):
```
superset/commands/chart/importers/v1/__init__.py:162: error: Item "UUID" of
"UUID | None" has no attribute "in_" [union-attr]
superset/commands/chart/importers/v1/__init__.py:162: error: Item "None" of
"UUID | None" has no attribute "in_" [union-attr]
```
superset-core's abstract `Chart` (imported as `CoreChart`) declares `uuid`
as a
plain `uuid: UUID | None` annotation rather than a column. `Slice` lists
`CoreChart` ahead of `ImportExportMixin`/`UUIDMixin`, which supplies the real
`uuid` Column, and defines no `uuid` of its own — so when superset-core's
sources are part of the same mypy run, mypy resolves `Slice.uuid` through
`CoreChart`'s annotation instead of the Column descriptor and rejects
`.in_()`.
Per-PR runs only check changed files, where `superset_core.*` is
`follow_imports = "skip"`, so the false positive appears in the nightly
full-repo lint only.
This adds a `# type: ignore[union-attr]` at the call site plus a matching
`warn_unused_ignores = false` override, extending the block that already
covers
the identical `SqlaTable.uuid.in_()` case in
`superset/mcp_service/dataset_scope.py`. The override is required: without it
the ignore is reported as `[unused-ignore]` in scoped runs, since global
`warn_unused_ignores` is on.
Reordering `Slice`'s base classes would address the annotation shadowing at
its
source, but that mutates the MRO of a declarative model with several mixins
to
silence a lint-only symptom, and `CoreChart` is first by design as the
host-replaced interface. This follows the established precedent instead.
No runtime behavior change.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — lint-only change.
### TESTING INSTRUCTIONS
Reproduce the failure by reverting both hunks and running mypy with
superset-core's sources in the same invocation:
```bash
mypy --check-untyped-defs \
superset/commands/chart/importers/v1/__init__.py \
superset-core/src/superset_core/common/models.py
```
Reverted: two `[union-attr]` errors at line 162. With the fix: clean.
The same file checked on its own (scoped mode) is clean either way, and is
also
clean with the fix applied — confirming the ignore is not flagged as unused.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #44943
- [ ] 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
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]