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


##########
superset/cli/test_db.py:
##########
@@ -120,14 +120,16 @@ def test_datetime(console: Console, engine: Engine) -> 
None:
     now = datetime.now()
 
     console.print("Inserting timestamp value...")
-    insert_stmt = insert(table).values(ts=now)
-    engine.execute(insert_stmt)
+    with engine.begin() as conn:
+        insert_stmt = insert(table).values(ts=now)

Review Comment:
   **Suggestion:** Add an explicit type annotation for this newly introduced 
SQL insert statement variable. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The added local variable `insert_stmt` is introduced without a type 
annotation, and its type can be annotated from the SQLAlchemy expression it 
stores. This matches the rule requiring type hints on relevant Python variables 
in new or modified code.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=42e024ea350f4a48a51485b7943e3de0&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=42e024ea350f4a48a51485b7943e3de0&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/cli/test_db.py
   **Line:** 124:124
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this newly introduced 
SQL insert statement variable.
   
   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%2F41917&comment_hash=18cfcab4b81715a31f6f475c946253f58e2bd2bfba2a5f5afe0d5fea7cec3915&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=18cfcab4b81715a31f6f475c946253f58e2bd2bfba2a5f5afe0d5fea7cec3915&reaction=dislike'>👎</a>



##########
superset/db_engine_specs/snowflake.py:
##########
@@ -265,12 +265,13 @@ def get_catalog_names(
 
         In Snowflake, a catalog is called a "database".
         """
-        return {
-            catalog
-            for (catalog,) in inspector.bind.execute(
-                text("SELECT DATABASE_NAME from information_schema.databases")
-            )
-        }
+        with inspector.bind.connect() as conn:

Review Comment:
   **Suggestion:** Add an explicit type annotation for the new connection 
variable so the updated method keeps full type coverage for introduced 
variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new local variable `conn` is introduced in modified Python code without 
any type annotation. Under the stated rule, newly added variables that can be 
annotated should include type hints, so this is a real violation.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=fa21608e7d2f496fbdc472c85dd65e4b&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=fa21608e7d2f496fbdc472c85dd65e4b&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/snowflake.py
   **Line:** 268:268
   **Comment:**
        *Custom Rule: Add an explicit type annotation for the new connection 
variable so the updated method keeps full type coverage for introduced 
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%2F41917&comment_hash=8190c9d8c69cf15371b420737392bcd5738e4b58c750dcf4b86bf8aff7499583&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=8190c9d8c69cf15371b420737392bcd5738e4b58c750dcf4b86bf8aff7499583&reaction=dislike'>👎</a>



##########
superset/utils/mock_data.py:
##########
@@ -205,11 +205,12 @@ def add_data(
         table = DBTable(table_name, metadata, *column_objects)
         metadata.create_all(engine)
 
-        if not append:
-            engine.execute(table.delete())
+        with engine.begin() as conn:
+            if not append:
+                conn.execute(table.delete())
 
-        data = generate_data(columns, num_rows)
-        engine.execute(table.insert(), data)
+            data = generate_data(columns, num_rows)

Review Comment:
   **Suggestion:** Add an explicit type annotation for the newly introduced 
`data` local variable so the generated payload type is declared. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new local variable `data` is assigned a generated list payload without 
any type annotation, and it is a newly introduced variable in modified Python 
code that can be annotated, so this matches the type-hint rule.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=9b7c6a9951a34f26a47cc29aaff8a4a5&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=9b7c6a9951a34f26a47cc29aaff8a4a5&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/utils/mock_data.py
   **Line:** 212:212
   **Comment:**
        *Custom Rule: Add an explicit type annotation for the newly introduced 
`data` local variable so the generated payload type is declared.
   
   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%2F41917&comment_hash=fb29a51b7bd12e1c1c8f90a03f06b56ffd6b89fcb290e11c01d8bbd04101e30c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=fb29a51b7bd12e1c1c8f90a03f06b56ffd6b89fcb290e11c01d8bbd04101e30c&reaction=dislike'>👎</a>



##########
tests/integration_tests/databases/commands/upload_test.py:
##########
@@ -114,12 +115,13 @@ def test_csv_upload_with_nulls():
             CSVReader({"null_values": ["N/A", "None"]}),
         ).run()
     with upload_database.get_sqla_engine() as engine:
-        data = engine.execute(text(f"SELECT * from 
{CSV_UPLOAD_TABLE}")).fetchall()  # noqa: S608
-        assert data == [
-            ("name1", None, "city1", "1-1-1980"),
-            ("name2", 29, None, "1-1-1981"),
-            ("name3", 28, "city3", "1-1-1982"),
-        ]
+        with engine.connect() as conn:
+            data = conn.execute(text(f"SELECT * from 
{CSV_UPLOAD_TABLE}")).fetchall()  # noqa: S608

Review Comment:
   **Suggestion:** Add an explicit type annotation for the local query result 
variable so this newly introduced variable is type-hinted. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new local variable `data` is introduced without any type annotation, and 
this file is Python code where a variable holding fetched rows can be annotated 
under the type-hint rule.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=c1b68c3c0d274345b70ea522097341dc&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=c1b68c3c0d274345b70ea522097341dc&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/integration_tests/databases/commands/upload_test.py
   **Line:** 119:119
   **Comment:**
        *Custom Rule: Add an explicit type annotation for the local query 
result variable so this newly introduced variable is type-hinted.
   
   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%2F41917&comment_hash=1adf7700c5f9a3148a4938b37a0604c5ef4b8a65035ad0953e4c2a2e9637e1b2&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=1adf7700c5f9a3148a4938b37a0604c5ef4b8a65035ad0953e4c2a2e9637e1b2&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