sadpandajoe commented on code in PR #43695:
URL: https://github.com/apache/superset/pull/43695#discussion_r4170894251


##########
superset/db_engine_specs/lint_metadata.py:
##########
@@ -272,10 +276,17 @@ def get_all_engine_specs_ast() -> list[dict[str, Any]]:  
# noqa: C901
                     if isinstance(item, ast.Assign):
                         for target in item.targets:
                             if isinstance(target, ast.Name) and target.id == 
"engine":
-                                # Check if engine value is non-empty string
                                 if isinstance(item.value, ast.Constant):
                                     has_non_empty_engine = 
bool(item.value.value)
                                 break
+                    elif isinstance(item, ast.AnnAssign):
+                        if (
+                            isinstance(item.target, ast.Name)
+                            and item.target.id == "engine"
+                        ):
+                            if isinstance(item.value, ast.Constant):
+                                has_non_empty_engine = bool(item.value.value)
+                            break

Review Comment:
   A declaration-only `engine: str` followed by `engine = "typed_engine"` now 
stops this scan before the actual assignment, so a valid TypedBaseEngineSpec 
disappears from the report and bypasses metadata validation; the previous 
scanner retained it. Could this continue past annotations without a value, with 
that declaration-then-assignment case added to the regression test?



##########
superset/db_engine_specs/parseable.py:
##########
@@ -41,11 +41,14 @@ class ParseableEngineSpec(BaseEngineSpec):
             "Parseable is a distributed log analytics database "
             "with SQL-like query interface."
         ),
+        "logo": "parseable.png",
+        "homepage_url": "https://www.parseable.com";,
         "categories": [DatabaseCategory.SEARCH_NOSQL, 
DatabaseCategory.OPEN_SOURCE],
         "pypi_packages": ["sqlalchemy-parseable"],
         "connection_string": (
             "parseable://{username}:{password}@{hostname}:{port}/{stream_name}"
         ),
+        "default_port": 8000,

Review Comment:
   With the advertised bare parseable:// scheme, the dialect selects HTTPS for 
every port except 80, so this new 8000 default produces https://host:8000 and 
fails TLS negotiation against the standard HTTP-on-8000 deployment. Could the 
template use parseable+http:// for this port, or keep an HTTPS-compatible 
default?



##########
tests/unit_tests/db_engine_specs/test_lint_metadata.py:
##########
@@ -0,0 +1,65 @@
+# 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.
+
+import tempfile
+from pathlib import Path
+from textwrap import dedent
+
+from superset.db_engine_specs import lint_metadata
+from superset.db_engine_specs.lint_metadata import get_all_engine_specs_ast
+
+
+def test_get_all_engine_specs_ast_annotated_attributes() -> None:
+    """
+    Ensure engine specs with type-annotated engine, engine_name, and metadata
+    are correctly discovered and parsed by get_all_engine_specs_ast.
+    """
+    specs_dir = Path(lint_metadata.__file__).parent
+    code = dedent(
+        """
+        from typing import Any
+        from superset.db_engine_specs.base import BaseEngineSpec
+
+        class TypedBaseEngineSpec(BaseEngineSpec):
+            engine: str = "typed_engine"
+            engine_name: str = "Typed Engine"
+            metadata: dict[str, Any] = {
+                "description": "A typed engine spec",
+            }
+        """
+    )
+
+    with tempfile.NamedTemporaryFile(
+        mode="w",
+        dir=specs_dir,

Review Comment:
   Agreed—two test invocations sharing this checkout can both discover the 
temporary TypedBaseEngineSpec files and fail the single-match assertion. Could 
the fixture live in tmp_path with the scanner redirected there instead of 
writing into the source package?



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