codeant-ai-for-open-source[bot] commented on code in PR #40960:
URL: https://github.com/apache/superset/pull/40960#discussion_r3501360106
##########
superset/daos/dashboard.py:
##########
@@ -431,36 +431,25 @@ def update_native_filters_config(
raise DashboardUpdateFailedError("Dashboard not found")
if attributes:
- metadata = json.loads(dashboard.json_metadata or "{}")
+ try:
+ _parsed = json.loads(dashboard.json_metadata or "{}")
+ except (json.JSONDecodeError, TypeError):
+ _parsed = {}
+ metadata = _parsed if isinstance(_parsed, dict) else {}
Review Comment:
**Suggestion:** Add an explicit type annotation for this newly introduced
local variable to satisfy the type-hint requirement. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is newly introduced Python code and `metadata` is a local variable that
can be annotated, but it has no explicit type hint. That matches the type-hint
rule violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5a091b0ba9044640a2fa4269035f9999&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=5a091b0ba9044640a2fa4269035f9999&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/daos/dashboard.py
**Line:** 438:438
**Comment:**
*Custom Rule: Add an explicit type annotation for this newly introduced
local variable to satisfy 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%2F40960&comment_hash=a8325b8bdfab84039d657859fc6a8657b6962569450dbf16d823e3ea86253c16&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40960&comment_hash=a8325b8bdfab84039d657859fc6a8657b6962569450dbf16d823e3ea86253c16&reaction=dislike'>👎</a>
##########
superset/daos/dashboard.py:
##########
@@ -431,36 +431,25 @@ def update_native_filters_config(
raise DashboardUpdateFailedError("Dashboard not found")
if attributes:
- metadata = json.loads(dashboard.json_metadata or "{}")
+ try:
+ _parsed = json.loads(dashboard.json_metadata or "{}")
+ except (json.JSONDecodeError, TypeError):
+ _parsed = {}
+ metadata = _parsed if isinstance(_parsed, dict) else {}
native_filter_configuration = metadata.get(
"native_filter_configuration", []
)
reordered_filter_ids: list[int] = attributes.get("reordered", [])
+ deleted_ids = set(attributes.get("deleted", []))
Review Comment:
**Suggestion:** Add a concrete type hint for this new set variable so its
intended element type is explicit. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This new local variable is a plain set assignment without an explicit type
annotation, so it violates the requirement to add type hints where applicable.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=513905bd040f47c6acf6886f33b3ce23&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=513905bd040f47c6acf6886f33b3ce23&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/daos/dashboard.py
**Line:** 443:443
**Comment:**
*Custom Rule: Add a concrete type hint for this new set variable so its
intended element type is explicit.
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%2F40960&comment_hash=7194f4b00909e34e39271efc8ddcee7dc876f24bcedcbf88a0c919432388fee3&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40960&comment_hash=7194f4b00909e34e39271efc8ddcee7dc876f24bcedcbf88a0c919432388fee3&reaction=dislike'>👎</a>
##########
superset/daos/dashboard.py:
##########
@@ -431,36 +431,25 @@ def update_native_filters_config(
raise DashboardUpdateFailedError("Dashboard not found")
if attributes:
- metadata = json.loads(dashboard.json_metadata or "{}")
+ try:
+ _parsed = json.loads(dashboard.json_metadata or "{}")
+ except (json.JSONDecodeError, TypeError):
+ _parsed = {}
+ metadata = _parsed if isinstance(_parsed, dict) else {}
native_filter_configuration = metadata.get(
"native_filter_configuration", []
)
reordered_filter_ids: list[int] = attributes.get("reordered", [])
+ deleted_ids = set(attributes.get("deleted", []))
+ modified_map = {f.get("id"): f for f in attributes.get("modified",
[])}
Review Comment:
**Suggestion:** Introduce a type annotation for this new mapping variable to
comply with the rule requiring type hints on relevant variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This newly added mapping variable has no explicit annotation, and it is a
relevant local variable that can be typed. The suggestion correctly identifies
a type-hint omission.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b8304ce615274ccda48929addf4b1585&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=b8304ce615274ccda48929addf4b1585&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/daos/dashboard.py
**Line:** 444:444
**Comment:**
*Custom Rule: Introduce a type annotation for this new mapping variable
to comply with the rule requiring type hints on 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%2F40960&comment_hash=da108ccc544dc3657db872bea9c54548399fc6391af38835842729a4bb85978a&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40960&comment_hash=da108ccc544dc3657db872bea9c54548399fc6391af38835842729a4bb85978a&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]