You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/10/09 08:19:41 UTC
(superset) 01/01: fix(mypy): silence superset-core mirror-case union-attr/assignment errors
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a commit to branch ultraset-missing-uuid-narrowing-datasource-reset-purge
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 5d32b4580f3f5a853735fe8802df8a2c4d1fae1d
Author: Joe Li <47...@users.noreply.github.com>
AuthorDate: Fri Oct 9 08:19:10 2026 +0000
fix(mypy): silence superset-core mirror-case union-attr/assignment errors
superset-core's abstract CoreModel classes (Dataset, Chart, KeyValue)
declare id/uuid as plain type hints for their public interface. Because
SqlaTable, Slice, and KeyValueEntry list those abstract classes first in
their MRO, mypy resolves .id/.uuid to the plain hint instead of the real
SQLAlchemy descriptor whenever superset-core's own sources are part of
the same mypy run (the nightly full-tree lint) — the same mechanism
already documented and ignored for dataset_scope.py, importers/v1, and
test_dataset_tools.py in pyproject.toml. Apply the same type: ignore +
warn_unused_ignores override pattern to the three newly affected call
sites in daos/datasource.py, commands/security/reset.py, and
test_purge_chart_detach.py.
Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
pyproject.toml | 14 +++++++++-----
superset/commands/security/reset.py | 3 ++-
superset/daos/datasource.py | 5 ++++-
.../commands/deletion_retention/test_purge_chart_detach.py | 2 +-
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 13e7701e54f..e63f340db50 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -404,16 +404,20 @@ module = [
]
warn_unused_ignores = false
-# 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.
+# The mirror case: superset-core declares SqlaTable's id/uuid/perm,
+# Chart's uuid, and KeyValue's uuid as plain value types, so column
+# expressions like SqlaTable.uuid.in_(), Slice.uuid.in_(), and
+# KeyValueEntry.uuid.is_() 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",
+ "superset.daos.datasource",
+ "superset.commands.security.reset",
+ "tests.unit_tests.commands.deletion_retention.test_purge_chart_detach",
]
warn_unused_ignores = false
diff --git a/superset/commands/security/reset.py b/superset/commands/security/reset.py
index d3abe9a546e..e05d308d0ef 100644
--- a/superset/commands/security/reset.py
+++ b/superset/commands/security/reset.py
@@ -79,7 +79,8 @@ class ResetSupersetCommand(BaseCommand):
db.session.query(Slice).delete()
config_uuid = FIXED_RESOURCE_KEYS[KeyValueResource.ALERT_REPORT_CONFIG]
db.session.query(KeyValueEntry).filter(
- KeyValueEntry.uuid.is_(None) | (KeyValueEntry.uuid != config_uuid)
+ KeyValueEntry.uuid.is_(None) # type: ignore[union-attr]
+ | (KeyValueEntry.uuid != config_uuid)
).delete()
# Non-admins will be deleted, so clean up ``created_by_fk`` and ``changed_by_fk`
_clear_preserved_config_audit_fields()
diff --git a/superset/daos/datasource.py b/superset/daos/datasource.py
index 7fda06813b3..a4795ff2f15 100644
--- a/superset/daos/datasource.py
+++ b/superset/daos/datasource.py
@@ -108,7 +108,10 @@ class DatasourceDAO(BaseDAO[Datasource]):
if model is Query:
# Query.perm and schema checks read the database for every member.
query = query.options(joinedload(Query.database))
- return {item.id: item for item in query.filter(model.id.in_(ids)).all()}
+ return {
+ item.id: item
+ for item in query.filter(model.id.in_(ids)).all() # type: ignore[union-attr]
+ }
@staticmethod
def build_dataset_query(
diff --git a/tests/unit_tests/commands/deletion_retention/test_purge_chart_detach.py b/tests/unit_tests/commands/deletion_retention/test_purge_chart_detach.py
index 5f1082c46eb..f82d8189386 100644
--- a/tests/unit_tests/commands/deletion_retention/test_purge_chart_detach.py
+++ b/tests/unit_tests/commands/deletion_retention/test_purge_chart_detach.py
@@ -200,7 +200,7 @@ def test_purge_detach_keeps_chart_history_and_etag(
dataset, chart, _, _ = _trashed_dataset_with_charts(versioned_session)
chart_id: int = chart.id
dataset_id: int = dataset.id
- chart_uuid: UUID = chart.uuid
+ chart_uuid: UUID = chart.uuid # type: ignore[assignment]
shadow: Any = version_class(Slice)
latest_before: Any = versioned_session.scalars(
sa.select(shadow)