chore: annotate important types (#36034)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Beto Dealmeida
2025-11-17 14:41:20 -05:00
committed by GitHub
parent 282f4e5de2
commit fb7d0e0e3d
12 changed files with 386 additions and 97 deletions

View File

@@ -36,7 +36,7 @@ from superset.exceptions import (
)
from superset.extensions import event_logger
from superset.sql.parse import sanitize_clause
from superset.superset_typing import Column, Metric, OrderBy
from superset.superset_typing import Column, Metric, OrderBy, QueryObjectDict
from superset.utils import json, pandas_postprocessing
from superset.utils.core import (
DTTM_ALIAS,
@@ -370,8 +370,8 @@ class QueryObject: # pylint: disable=too-many-instance-attributes
)
)
def to_dict(self) -> dict[str, Any]:
query_object_dict = {
def to_dict(self) -> QueryObjectDict:
query_object_dict: QueryObjectDict = {
"apply_fetch_values_predicate": self.apply_fetch_values_predicate,
"columns": self.columns,
"extras": self.extras,
@@ -412,7 +412,8 @@ class QueryObject: # pylint: disable=too-many-instance-attributes
the use-provided inputs to bounds, which may be time-relative (as in
"5 days ago" or "now").
"""
cache_dict = self.to_dict()
# Cast to dict[str, Any] for mutation operations
cache_dict: dict[str, Any] = dict(self.to_dict())
cache_dict.update(extra)
# TODO: the below KVs can all be cleaned up and moved to `to_dict()` at some