codeant-ai-for-open-source[bot] commented on code in PR #41917:
URL: https://github.com/apache/superset/pull/41917#discussion_r3555874052
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -344,24 +344,25 @@ def get_catalog_names(
The command returns columns: Catalog, Type, Comment
"""
try:
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- catalogs = set()
-
- for row in result:
- try:
- if hasattr(row, "keys") and "Catalog" in row.keys():
- catalogs.add(row["Catalog"])
- elif hasattr(row, "Catalog"):
- catalogs.add(row.Catalog)
- else:
- catalogs.add(row[0])
- except (AttributeError, TypeError, IndexError, KeyError) as ex:
- logger.warning(
- "Unable to extract catalog name from row: %s (%s)",
row, ex
- )
- continue
-
- return catalogs
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
+ catalogs = set()
Review Comment:
**Suggestion:** Add an explicit local type annotation for the catalog
accumulator so its element type is clear and enforced. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new local variable `catalogs` is introduced without an explicit type
hint even though its element type can be annotated (for example, `set[str]`).
This matches the rule requiring type hints on new or modified Python variables
that can be annotated.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=036d26ec485140de9e776477c7a1c562&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=036d26ec485140de9e776477c7a1c562&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/starrocks.py
**Line:** 349:349
**Comment:**
*Custom Rule: Add an explicit local type annotation for the catalog
accumulator so its element type is clear and enforced.
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=44cabe4190e0b091890c19f0b70ca1fb5833b1aff287e54d1de3dcf65dde01f8&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=44cabe4190e0b091890c19f0b70ca1fb5833b1aff287e54d1de3dcf65dde01f8&reaction=dislike'>👎</a>
##########
superset/db_engine_specs/starrocks.py:
##########
@@ -375,8 +376,9 @@ def get_schema_names(cls, inspector: Inspector) -> set[str]:
(e.g., "catalog." sets the context to that catalog).
"""
try:
- result = inspector.bind.execute(text("SHOW DATABASES"))
- return {row[0] for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW DATABASES"))
Review Comment:
**Suggestion:** Add an explicit type annotation for the query result
variable to satisfy the type-hint requirement for new local variables.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new local variable `result` is introduced without an explicit type
annotation. Since the rule covers new Python variables that can be annotated,
this is a real type-hint omission.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8786d6d4de5147418cb1224814f868ec&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8786d6d4de5147418cb1224814f868ec&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/starrocks.py
**Line:** 380:380
**Comment:**
*Custom Rule: Add an explicit type annotation for the query result
variable to satisfy the type-hint requirement for new local 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=85e8d54d2e126324ad218475f8af895f7a0081ca1fab1d22ab7608aea94b9512&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=85e8d54d2e126324ad218475f8af895f7a0081ca1fab1d22ab7608aea94b9512&reaction=dislike'>👎</a>
##########
tests/integration_tests/conftest.py:
##########
@@ -146,15 +146,15 @@ def setup_sample_data() -> Any:
db.session.commit()
-def drop_from_schema(engine: Engine, schema_name: str):
- schemas = engine.execute(text("SHOW SCHEMAS")).fetchall() # noqa: F541
+def drop_from_schema(conn: Connection, schema_name: str):
Review Comment:
**Suggestion:** Add an explicit return type hint to this newly introduced
function definition. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new helper function is missing a return type annotation, which violates
the Python type-hints rule for newly added or modified code.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9a21b9acfea64990afe42dab40481dff&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9a21b9acfea64990afe42dab40481dff&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/conftest.py
**Line:** 149:149
**Comment:**
*Custom Rule: Add an explicit return type hint to this newly introduced
function definition.
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=a7773f3feb1c2bfbc99f54732bd1780bd2243443c3d726d0257f2aeda89e228c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=a7773f3feb1c2bfbc99f54732bd1780bd2243443c3d726d0257f2aeda89e228c&reaction=dislike'>👎</a>
##########
superset/db_engine_specs/doris.py:
##########
@@ -326,8 +327,9 @@ def get_catalog_names(
CatalogId, CatalogName, Type, IsCurrent, CreateTime, LastUpdateTime,
Comment
We need to extract just the CatalogName column.
"""
- result = inspector.bind.execute(text("SHOW CATALOGS"))
- return {row.CatalogName for row in result}
+ with inspector.engine.connect() as conn:
+ result = conn.execute(text("SHOW CATALOGS"))
Review Comment:
**Suggestion:** Add an explicit type annotation for the newly introduced
query result variable to satisfy the type-hint requirement for relevant
variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new local variable `result` is introduced in modified Python code
without a type annotation, and it is the kind of relevant variable that can be
annotated. This matches the type-hint requirement violation.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7f3c07ae71134786b54cc13dcbf7f647&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7f3c07ae71134786b54cc13dcbf7f647&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/doris.py
**Line:** 331:331
**Comment:**
*Custom Rule: Add an explicit type annotation for the newly introduced
query result variable to satisfy the type-hint requirement for relevant
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=2dabc6e2450be3c090edec893dcf68059e936d42206b31b4c4b97828b1880489&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=2dabc6e2450be3c090edec893dcf68059e936d42206b31b4c4b97828b1880489&reaction=dislike'>👎</a>
##########
scripts/benchmark_migration.py:
##########
@@ -153,10 +153,11 @@ def main( # noqa: C901
)
print(f"Migration goes from {down_revision} to {revision}")
- current_revision = db.engine.execute(
- text("SELECT version_num FROM alembic_version")
- ).scalar()
- print(f"Current version of the DB is {current_revision}")
+ with db.engine.connect() as conn:
+ current_revision = conn.execute(
+ text("SELECT version_num FROM alembic_version")
+ ).scalar()
Review Comment:
**Suggestion:** Add an explicit type annotation for the newly introduced
revision value variable to satisfy the type-hint requirement for relevant
variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new local variable `current_revision` is inferred from a database scalar
result and has no explicit type annotation. This matches the Python type-hint
rule for relevant variables that can be annotated.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f3746a7b0d6c4d7a9ec5b92ee67e9dec&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f3746a7b0d6c4d7a9ec5b92ee67e9dec&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:** scripts/benchmark_migration.py
**Line:** 156:159
**Comment:**
*Custom Rule: Add an explicit type annotation for the newly introduced
revision value variable to satisfy the type-hint requirement for relevant
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=3769a465e7b785fc99ead6aa0ce4d9e2bf09a044a7fbcb5c7858b7d72e2def1f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=3769a465e7b785fc99ead6aa0ce4d9e2bf09a044a7fbcb5c7858b7d72e2def1f&reaction=dislike'>👎</a>
##########
superset/db_engine_specs/impala.py:
##########
@@ -96,11 +96,12 @@ def convert_dttm(
@classmethod
def get_schema_names(cls, inspector: Inspector) -> set[str]:
- return {
- row[0]
- for row in inspector.engine.execute(text("SHOW SCHEMAS"))
- if not row[0].startswith("_")
- }
+ with inspector.engine.connect() as conn:
Review Comment:
**Suggestion:** Add an explicit type annotation for the new local connection
variable by assigning the connection object to a typed variable before entering
the context manager. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new code introduces a local variable `conn` without any type annotation.
The rule requires type hints for relevant variables that can be annotated, and
this connection variable is a candidate for annotation.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=833314d79062425791100a6673693c6c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=833314d79062425791100a6673693c6c&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/impala.py
**Line:** 99:99
**Comment:**
*Custom Rule: Add an explicit type annotation for the new local
connection variable by assigning the connection object to a typed variable
before entering the context manager.
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=749a018dc892f28ca53445020ed4a1c2441177bc43dbfad5ab4556f2ec3cd815&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41917&comment_hash=749a018dc892f28ca53445020ed4a1c2441177bc43dbfad5ab4556f2ec3cd815&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]