codeant-ai-for-open-source[bot] commented on code in PR #41979:
URL: https://github.com/apache/superset/pull/41979#discussion_r3566807555
##########
superset/extensions/metadb.py:
##########
@@ -445,15 +445,16 @@ def insert_row(self, row: Row) -> int:
query = self._table.insert().values(**row)
with self.engine_context() as engine:
- connection = engine.connect()
- result = connection.execute(query)
+ with engine.begin() as connection:
+ result = connection.execute(query)
Review Comment:
**Suggestion:** Add an explicit type annotation to this newly introduced
execution result variable to satisfy the mandatory type-hinting requirement.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is also newly added Python code, and `result` is a local variable that
can be annotated but currently is not. The omission fits the custom
type-hinting rule.
</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=7ca38f062afe4047ad6a4f64b598f060&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=7ca38f062afe4047ad6a4f64b598f060&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/extensions/metadb.py
**Line:** 449:449
**Comment:**
*Custom Rule: Add an explicit type annotation to this newly introduced
execution result variable to satisfy the mandatory type-hinting 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%2F41979&comment_hash=df91ed4b174a674a71f785dc8ab1764254f5716624adbfd159e40fef388d4928&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41979&comment_hash=df91ed4b174a674a71f785dc8ab1764254f5716624adbfd159e40fef388d4928&reaction=dislike'>๐</a>
##########
superset/extensions/metadb.py:
##########
@@ -417,12 +417,12 @@ def get_data(
query = self._build_sql(bounds, order, limit, offset)
with self.engine_context() as engine:
- connection = engine.connect()
- rows = connection.execute(query)
- for i, row in enumerate(rows):
- data = dict(zip(self.columns, row, strict=False))
- data["rowid"] = data[self._rowid] if self._rowid else i
- yield data
+ with engine.connect() as connection:
+ rows = connection.execute(query)
Review Comment:
**Suggestion:** Add an explicit type annotation to this local query result
variable so it complies with the required type-hinting rule. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is newly added Python code and the local variable `rows` is
type-annotatable, but it is introduced without an explicit type hint. That
matches the rule requiring type hints on relevant new variables.
</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=582131e7be964a6ebef31be9b80a6560&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=582131e7be964a6ebef31be9b80a6560&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/extensions/metadb.py
**Line:** 421:421
**Comment:**
*Custom Rule: Add an explicit type annotation to this local query
result variable so it complies with the required type-hinting rule.
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%2F41979&comment_hash=0dead9e7b7013ec70140ab8cbd4e434e745c054bcfa50d34a8476c6584db0e4f&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41979&comment_hash=0dead9e7b7013ec70140ab8cbd4e434e745c054bcfa50d34a8476c6584db0e4f&reaction=dislike'>๐</a>
##########
tests/unit_tests/extensions/test_sqlalchemy.py:
##########
@@ -137,9 +141,9 @@ def test_superset(mocker: MockerFixture, app_context: None,
table1: None) -> Non
# Skip test if superset:// dialect can't be loaded (common in Docker)
pytest.skip(f"Superset dialect not available: {e}")
- conn = engine.connect()
- results = conn.execute(text('SELECT * FROM "database1.table1"'))
- assert list(results) == [(1, 10), (2, 20)]
+ with engine.connect() as conn:
+ results = conn.execute(text('SELECT * FROM "database1.table1"'))
Review Comment:
**Suggestion:** Add an explicit type annotation for `results` when assigning
query output so the new variable follows the type-hint requirement.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new local variable `results` is introduced without any type annotation
in modified Python code. Under the stated type-hint rule, this is a relevant
variable that can be annotated, so the suggestion matches a real 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=d849a841ad1c4aa0bda1c29175de47c0&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=d849a841ad1c4aa0bda1c29175de47c0&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/extensions/test_sqlalchemy.py
**Line:** 145:145
**Comment:**
*Custom Rule: Add an explicit type annotation for `results` when
assigning query output so the new variable follows 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%2F41979&comment_hash=b22dd4f22c2d25412736b232f366ac3ff497be1cc019c133caca560e2f9c612e&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41979&comment_hash=b22dd4f22c2d25412736b232f366ac3ff497be1cc019c133caca560e2f9c612e&reaction=dislike'>๐</a>
##########
tests/unit_tests/extensions/test_sqlalchemy.py:
##########
@@ -178,9 +182,9 @@ def test_superset_limit(mocker: MockerFixture, app_context:
None, table1: None)
# Skip test if superset:// dialect can't be loaded (common in Docker)
pytest.skip(f"Superset dialect not available: {e}")
- conn = engine.connect()
- results = conn.execute(text('SELECT * FROM "database1.table1"'))
- assert list(results) == [(1, 10)]
+ with engine.connect() as conn:
Review Comment:
**Suggestion:** Add an explicit type annotation for `results` in this new
assignment to keep local variables in modified code type-hinted. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
This is another newly added `results` assignment in modified Python code,
and it also lacks an explicit type annotation. That fits the type-hint rule for
relevant variables.
</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=dde051e6056a4362ab9b0fa86d1b3239&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=dde051e6056a4362ab9b0fa86d1b3239&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/extensions/test_sqlalchemy.py
**Line:** 185:185
**Comment:**
*Custom Rule: Add an explicit type annotation for `results` in this new
assignment to keep local variables in modified code 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%2F41979&comment_hash=11e9dd59538ccf5eafb53d9e6bf5a1dffc49a3e3f01c7cd01b9d1acf3820a58e&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41979&comment_hash=11e9dd59538ccf5eafb53d9e6bf5a1dffc49a3e3f01c7cd01b9d1acf3820a58e&reaction=dislike'>๐</a>
##########
tests/unit_tests/extensions/test_sqlalchemy.py:
##########
@@ -257,22 +261,27 @@ def test_dml(
# Skip test if superset:// dialect can't be loaded (common in Docker)
pytest.skip(f"Superset dialect not available: {e}")
- conn = engine.connect()
-
- conn.execute(text('INSERT INTO "database1.table1" (a, b) VALUES (3, 30)'))
- results = conn.execute(text('SELECT * FROM "database1.table1"'))
- assert list(results) == [(1, 10), (2, 20), (3, 30)]
- conn.execute(text('UPDATE "database1.table1" SET b=35 WHERE a=3'))
- results = conn.execute(text('SELECT * FROM "database1.table1"'))
- assert list(results) == [(1, 10), (2, 20), (3, 35)]
- conn.execute(text('DELETE FROM "database1.table1" WHERE b>20'))
- results = conn.execute(text('SELECT * FROM "database1.table1"'))
- assert list(results) == [(1, 10), (2, 20)]
-
- with pytest.raises(ProgrammingError) as excinfo:
- conn.execute(
- text("""INSERT INTO "database2.table2" (a, b) VALUES (3,
'thirty')""")
- )
+ with engine.begin() as conn:
+ conn.execute(text('INSERT INTO "database1.table1" (a, b) VALUES (3,
30)'))
+ with engine.connect() as conn:
+ results = conn.execute(text('SELECT * FROM "database1.table1"'))
+ assert list(results) == [(1, 10), (2, 20), (3, 30)]
+ with engine.begin() as conn:
+ conn.execute(text('UPDATE "database1.table1" SET b=35 WHERE a=3'))
+ with engine.connect() as conn:
+ results = conn.execute(text('SELECT * FROM "database1.table1"'))
+ assert list(results) == [(1, 10), (2, 20), (3, 35)]
+ with engine.begin() as conn:
+ conn.execute(text('DELETE FROM "database1.table1" WHERE b>20'))
+ with engine.connect() as conn:
+ results = conn.execute(text('SELECT * FROM "database1.table1"'))
+ assert list(results) == [(1, 10), (2, 20)]
+
+ with engine.begin() as conn:
+ with pytest.raises(ProgrammingError) as excinfo:
Review Comment:
**Suggestion:** Add an explicit type annotation for `excinfo` in this new
context-manager binding to satisfy the type-hint rule for relevant variables.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The code introduces `excinfo` as a new variable in modified Python code
without any annotation. Since the rule covers relevant variables that can be
annotated, this is a valid type-hint finding.
</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=7c92e82808cf443fa1edb9c7fb80d89e&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=7c92e82808cf443fa1edb9c7fb80d89e&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/extensions/test_sqlalchemy.py
**Line:** 281:281
**Comment:**
*Custom Rule: Add an explicit type annotation for `excinfo` in this new
context-manager binding to satisfy the type-hint rule 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%2F41979&comment_hash=6be038d7a635fd440ba51be27566dc64656e2183e64483d99f69c52c12040551&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41979&comment_hash=6be038d7a635fd440ba51be27566dc64656e2183e64483d99f69c52c12040551&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]