bito-code-review[bot] commented on code in PR #43232:
URL: https://github.com/apache/superset/pull/43232#discussion_r4142909072


##########
superset/utils/core.py:
##########
@@ -211,6 +211,18 @@ class AnnotationType(StrEnum):
     TIME_SERIES = "TIME_SERIES"
 
 
+# Annotation source types whose ``value`` field references another Chart
+# (resolved to a local Slice.id on import / serialised back to UUID on export).
+# Add new chart-referencing source types here; all consumers pick them up
+# automatically via this single definition.
+ANNOTATION_SOURCE_TYPES_WITH_CHART_REFERENCE: frozenset[str] = frozenset(
+    {
+        "table",
+        "line",
+    }
+)

Review Comment:
   <!-- Bito Reply -->
   The update is noted. Using the constant 
`ANNOTATION_SOURCE_TYPES_WITH_CHART_REFERENCE` in `query_context_processor.py` 
ensures that any future additions to the chart-referencing source types are 
automatically reflected in the RLS cache-key logic, preventing the divergence 
identified by the reviewer.



##########
superset/commands/annotation_layer/importers/v1/__init__.py:
##########
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from typing import Any, Optional
+
+from marshmallow import Schema
+from sqlalchemy.orm import Session  # noqa: F401
+
+from superset.annotation_layers.schemas import ImportV1AnnotationLayerSchema
+from superset.commands.annotation_layer.exceptions import 
AnnotationLayerImportError
+from superset.commands.annotation_layer.importers.v1.utils import (
+    import_annotation_layer,
+)
+from superset.commands.importers.v1 import ImportModelsCommand
+from superset.daos.annotation_layer import AnnotationLayerDAO
+
+
+class ImportAnnotationLayersCommand(ImportModelsCommand):
+    """Import Annotation Layers"""
+
+    dao = AnnotationLayerDAO
+    model_name = "annotation_layer"
+    prefix = "annotation_layers/"
+    schemas: dict[str, Schema] = {
+        "annotation_layers/": ImportV1AnnotationLayerSchema(),
+    }
+    import_error = AnnotationLayerImportError
+
+    @staticmethod
+    def _import(
+        configs: dict[str, Any],
+        overwrite: bool = False,
+        contents: Optional[dict[str, Any]] = None,
+    ) -> None:
+        """
+        Import annotation layer configs; pass overwrite to each import call;
+        contents is accepted but not used.
+        """
+
+        for file_name, config in configs.items():
+            if file_name.startswith("annotation_layers/"):

Review Comment:
   <!-- Bito Reply -->
   Maintaining consistency across the v1 importers is a reasonable approach. 
Since the other importers follow the same pattern of using a literal prefix, 
keeping this implementation consistent avoids introducing a discrepancy in the 
codebase.



##########
superset/commands/importers/v1/utils.py:
##########
@@ -192,6 +192,7 @@ def load_configs(
         if not content:
             continue
 
+        config: Any = None

Review Comment:
   <!-- Bito Reply -->
   The reviewer's suggestion to use `dict[str, Any] | None` is intended to 
improve static type checking by allowing mypy to validate the schema branch and 
the `isinstance(config, dict)` guard. While using `Any` avoids potential type 
errors when loading YAML, it does bypass static analysis for subsequent 
`config` access. If the current implementation relies on the flexibility of 
`Any` to handle both scalars and lists, you may choose to keep it, but 
annotating the type more specifically is generally preferred to maintain type 
safety.
   
   **superset/commands/importers/v1/utils.py**
   ```
   config: Any = None
   ```



-- 
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]

Reply via email to