This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch ultraset-mh-chart-import-uuid-in-2
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 92e4a19d11928c6118634d5d0297c1b85fedc08b
Author: Joe Li <[email protected]>
AuthorDate: Sat Oct 3 08:15:51 2026 +0000

    fix(mypy): ignore false-positive union-attr on Slice.uuid.in_()
    
    superset-core's Chart class (imported as CoreChart) declares uuid as a
    plain `uuid: UUID | None` annotation. Slice lists CoreChart ahead of
    ImportExportMixin/UUIDMixin, which supplies the real uuid Column, so
    when superset-core's sources are part of the same mypy run (the
    nightly full-repo pre-commit sweep, not per-PR scoped runs), mypy
    resolves Slice.uuid through CoreChart's plain annotation instead of
    the Column descriptor, and Slice.uuid.in_() fails with
    "Item ... of UUID | None has no attribute in_".
    
    This mirrors the already-ignored SqlaTable.uuid.in_() case in
    superset/mcp_service/dataset_scope.py. Add the same type: ignore plus
    the matching warn_unused_ignores override so the ignore doesn't become
    "unused" in a per-PR scoped mypy run, where superset-core isn't
    directly checked and the false positive doesn't occur.
    
    Co-Authored-By: Claude Sonnet 5 <[email protected]>
---
 pyproject.toml                                   | 10 ++++++----
 superset/commands/chart/importers/v1/__init__.py |  7 ++++++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 4fb72805e15..31bca4ee2a7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -405,14 +405,16 @@ module = [
 ]
 warn_unused_ignores = false
 
-# The mirror case: superset-core declares SqlaTable's id/uuid/perm as plain
-# value types, so column expressions like SqlaTable.uuid.in_() only need a
-# type: ignore when superset-core's sources are part of the same mypy run
-# (full-repo lint) and not when only changed files are checked.
+# The mirror case: superset-core declares SqlaTable's id/uuid/perm, and
+# Chart's uuid, as plain value types, so column expressions like
+# SqlaTable.uuid.in_() and Slice.uuid.in_() only need a type: ignore when
+# superset-core's sources are part of the same mypy run (full-repo lint)
+# and not when only changed files are checked.
 [[tool.mypy.overrides]]
 module = [
     "superset.mcp_service.dataset_scope",
     "tests.unit_tests.mcp_service.dataset.tool.test_dataset_tools",
+    "superset.commands.chart.importers.v1",
 ]
 warn_unused_ignores = false
 
diff --git a/superset/commands/chart/importers/v1/__init__.py 
b/superset/commands/chart/importers/v1/__init__.py
index a2552d0a1a7..69779de61a7 100644
--- a/superset/commands/chart/importers/v1/__init__.py
+++ b/superset/commands/chart/importers/v1/__init__.py
@@ -159,7 +159,12 @@ class ImportChartsCommand(ImportModelsCommand):
             {
                 str(chart_uuid)
                 for (chart_uuid,) in db.session.query(Slice.uuid).filter(
-                    Slice.uuid.in_(dependency_chart_uuids)
+                    # Slice.uuid comes only from the 
ImportExportMixin/UUIDMixin
+                    # chain, so in a full-repo mypy run mypy resolves it 
through
+                    # CoreChart's plain `uuid: UUID | None` annotation instead 
of
+                    # the Column descriptor; same false positive already 
ignored
+                    # at superset/mcp_service/dataset_scope.py:131.
+                    Slice.uuid.in_(dependency_chart_uuids)  # type: 
ignore[union-attr]
                 )
             }
             if dependency_chart_uuids

Reply via email to