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


##########
superset/db_engine_specs/clickhouse.py:
##########
@@ -132,7 +132,10 @@ def convert_dttm(
         if isinstance(sqla_type, types.Date):
             return f"toDate('{dttm.date().isoformat()}')"
         if isinstance(sqla_type, types.DateTime):
-            return f"""toDateTime('{dttm.isoformat(sep=" ", 
timespec="seconds")}')"""
+            if dttm.tzinfo is not None and dttm.utcoffset() is not None:
+                dttm = dttm.astimezone(timezone.utc).replace(tzinfo=None)
+            formatted_dttm = dttm.isoformat(sep=" ", timespec="seconds")

Review Comment:
   **Suggestion:** Add an explicit type annotation for this newly introduced 
local variable to comply with the type-hint requirement for annotatable 
variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly introduced local variable in modified Python code, and it is 
not annotated even though its type is clearly inferable as a string. That 
matches the custom rule requiring type hints for annotatable variables.
   </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=63ebee66a0a7404bbf06b8f2e8c5f102&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=63ebee66a0a7404bbf06b8f2e8c5f102&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/db_engine_specs/clickhouse.py
   **Line:** 137:137
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this newly introduced 
local variable to comply with the type-hint requirement for annotatable 
variables.
   
   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%2F41579&comment_hash=061d74d222b36bcb321639ec9c68f8d8d9398663ebfe7f3ce2c1c320d8461823&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41579&comment_hash=061d74d222b36bcb321639ec9c68f8d8d9398663ebfe7f3ce2c1c320d8461823&reaction=dislike'>👎</a>



##########
tests/unit_tests/db_engine_specs/test_clickhouse.py:
##########
@@ -62,6 +62,26 @@ def test_convert_dttm(
     assert_convert_dttm(spec, target_type, expected_result, dttm)
 
 
+def test_convert_dttm_normalizes_aware_datetime_to_utc() -> None:
+    from superset.db_engine_specs.clickhouse import (
+        ClickHouseEngineSpec as spec,  # noqa: N813
+    )
+
+    aware_dttm = datetime(
+        2026,
+        6,
+        30,
+        12,
+        30,
+        tzinfo=timezone(timedelta(hours=3)),
+    )

Review Comment:
   **Suggestion:** Add an explicit type annotation to `aware_dttm` to comply 
with the type-hint requirement for relevant new variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new local variable `aware_dttm` is introduced without a type annotation, 
and it is clearly annotatable as a `datetime`. This matches the Python 
type-hint rule for relevant variables.
   </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=ac90ed3a8d4a41c0b1f6136c94e8859a&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=ac90ed3a8d4a41c0b1f6136c94e8859a&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/db_engine_specs/test_clickhouse.py
   **Line:** 70:77
   **Comment:**
        *Custom Rule: Add an explicit type annotation to `aware_dttm` to comply 
with the type-hint requirement for relevant new variables.
   
   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%2F41579&comment_hash=0f70b5f14659b60346e2917b8a4789cfd17c94ba177016beab389ce3a52c9044&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41579&comment_hash=0f70b5f14659b60346e2917b8a4789cfd17c94ba177016beab389ce3a52c9044&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