This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new e04d38a85f2 fix(mypy): resolve the dataset-scope and datasource-perm
errors from the full-repo lint (#44610)
e04d38a85f2 is described below
commit e04d38a85f2e2e8b8acded26b1536a78a59fe559
Author: Joe Li <[email protected]>
AuthorDate: Thu Sep 24 13:30:54 2026 -0700
fix(mypy): resolve the dataset-scope and datasource-perm errors from the
full-repo lint (#44610)
Co-authored-by: Claude Sonnet 5 <[email protected]>
---
pyproject.toml | 11 +++++++++++
superset/mcp_service/dataset_scope.py | 6 +++++-
tests/unit_tests/charts/semantic_view_chart_filter_test.py | 9 ++++++---
.../unit_tests/mcp_service/dataset/tool/test_dataset_tools.py | 4 +++-
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 3756ebb7d23..01f70ecc867 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -398,6 +398,17 @@ 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.
+[[tool.mypy.overrides]]
+module = [
+ "superset.mcp_service.dataset_scope",
+ "tests.unit_tests.mcp_service.dataset.tool.test_dataset_tools",
+]
+warn_unused_ignores = false
+
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
diff --git a/superset/mcp_service/dataset_scope.py
b/superset/mcp_service/dataset_scope.py
index e0e1c320925..ba50dd37580 100644
--- a/superset/mcp_service/dataset_scope.py
+++ b/superset/mcp_service/dataset_scope.py
@@ -124,7 +124,11 @@ class DatasetScopeFilter(BaseFilter): # pylint:
disable=too-few-public-methods
def apply(self, query: "Query", value: frozenset[UUID]) -> "Query":
from superset.connectors.sqla.models import SqlaTable
- return query.filter(SqlaTable.uuid.in_(value))
+ # SqlaTable.uuid is an unannotated Column, so mypy sees the raw
+ # nullable value type here instead of an InstrumentedAttribute; same
+ # false positive already ignored at
+ # superset/connectors/sqla/models.py:2491.
+ return query.filter(SqlaTable.uuid.in_(value)) # type:
ignore[union-attr]
def parse_dataset_role_allowlist(config: Any) -> dict[str, set[UUID]] | None:
diff --git a/tests/unit_tests/charts/semantic_view_chart_filter_test.py
b/tests/unit_tests/charts/semantic_view_chart_filter_test.py
index 053dd0b02d6..1abd136fbd1 100644
--- a/tests/unit_tests/charts/semantic_view_chart_filter_test.py
+++ b/tests/unit_tests/charts/semantic_view_chart_filter_test.py
@@ -399,9 +399,12 @@ def
test_hard_deleted_dataset_retains_only_schema_catalog_list_access(
)
session.add(chart)
session.flush()
- dataset_perm: str = table.perm
- schema_perm: str = table.schema_perm
- catalog_perm: str = table.catalog_perm
+ dataset_perm: str | None = table.perm
+ schema_perm: str | None = table.schema_perm
+ catalog_perm: str | None = table.catalog_perm
+ assert dataset_perm is not None
+ assert schema_perm is not None
+ assert catalog_perm is not None
grant_perm: str = {
"datasource_access": dataset_perm,
"schema_access": schema_perm,
diff --git a/tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
b/tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
index 3fdce64819d..781231f26c9 100644
--- a/tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
+++ b/tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py
@@ -2709,7 +2709,9 @@ async def
test_description_discovery_uses_dao_search_and_exposes_alternatives(
# UUID union (including an inaccessible dataset) is intersected by
# the existing access filter before count and page boundaries.
identifiers = (
- session.query(SqlaTable.uuid).filter(SqlaTable.id.in_([1,
3])).all()
+ session.query(SqlaTable.uuid)
+ .filter(SqlaTable.id.in_([1, 3])) # type: ignore[attr-defined]
+ .all()
)
scoped_rows, scoped_count = DatasetDAO.list(
search="Order",