codeant-ai-for-open-source[bot] commented on code in PR #38766:
URL: https://github.com/apache/superset/pull/38766#discussion_r3530225406


##########
superset/models/sql_lab.py:
##########
@@ -446,14 +446,32 @@ def adhoc_column_to_sqla(
         :rtype: tuple[sqlalchemy.sql.ColumnElement, Optional[GenericDataType]]
         """
         label = get_column_name(col)
+        sql_expression = col["sqlExpression"]
+        time_grain = col.get("timeGrain")
+        has_timegrain = col.get("columnType") == "BASE_AXIS" and time_grain
+        is_dttm = False

Review Comment:
   **Suggestion:** Add explicit type annotations for the newly introduced local 
variables initialized from dynamic values or None so the method fully complies 
with the type-hint requirement. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The custom rule requires type hints for newly added Python variables that 
can be annotated. These local variables are introduced in the new hunk without 
explicit annotations, and their types are not fully obvious from assignment 
alone (especially the values derived from `col.get(...)`), so the suggestion 
identifies a real rule violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6c962ac4229d4c55a9fcfac3d2b46d1e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6c962ac4229d4c55a9fcfac3d2b46d1e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/models/sql_lab.py
   **Line:** 449:452
   **Comment:**
        *Custom Rule: Add explicit type annotations for the newly introduced 
local variables initialized from dynamic values or None so the method fully 
complies with the type-hint requirement.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38766&comment_hash=da6acc9a0b17251833f7970c71ed09d694f7365b1a71a62f1ec422586ee35382&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38766&comment_hash=da6acc9a0b17251833f7970c71ed09d694f7365b1a71a62f1ec422586ee35382&reaction=dislike'>👎</a>



##########
tests/unit_tests/models/sql_lab_test.py:
##########
@@ -133,3 +136,96 @@ def test_sql_tables_mixin_invalid_sql_returns_empty_list(
         else klass(database=MagicMock())
     )
     assert instance.sql_tables == []
+
+
+def _query_with_column(column: dict) -> Query:
+    """Build an unsaved-dataset ``Query`` exposing a single result column."""
+    query = Query(
+        database=Database(database_name="db", sqlalchemy_uri="sqlite://"),
+        database_id=1,
+        sql="SELECT ds FROM t",
+    )
+    query.extra = {"columns": [column]}
+    return query
+
+
+def _compile(column_element) -> str:

Review Comment:
   **Suggestion:** Add an explicit type hint for the `column_element` parameter 
so the helper function is fully typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The custom rule requires type hints on new or modified Python functions when 
parameters can be annotated. This helper omits a type annotation for 
`column_element`, so the violation is real.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=15fccb03e07d414d958290d15df72ca7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=15fccb03e07d414d958290d15df72ca7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/models/sql_lab_test.py
   **Line:** 152:152
   **Comment:**
        *Custom Rule: Add an explicit type hint for the `column_element` 
parameter so the helper function is fully typed.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38766&comment_hash=df531afab1189031a717870624446af97f00882d91ab32473f7806b85084072a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38766&comment_hash=df531afab1189031a717870624446af97f00882d91ab32473f7806b85084072a&reaction=dislike'>👎</a>



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