codeant-ai-for-open-source[bot] commented on code in PR #41176:
URL: https://github.com/apache/superset/pull/41176#discussion_r3555071225
##########
superset/commands/dashboard/update.py:
##########
@@ -64,23 +64,31 @@ def __init__(self, model_id: int, data: dict[str, Any]):
def run(self) -> Model:
self.validate()
assert self._model is not None
- self.process_tab_diff()
- self.process_native_filter_diff()
-
- # Update tags
- if (tags := self._properties.pop("tags", None)) is not None:
- update_tags(ObjectType.dashboard, self._model.id,
self._model.tags, tags)
-
- # Re-serialize position_json to escape 4-byte Unicode characters
- if position_json := self._properties.get("position_json"):
- self._properties["position_json"] =
json.dumps(json.loads(position_json))
-
- dashboard = DashboardDAO.update(self._model, self._properties)
- if self._properties.get("json_metadata"):
- DashboardDAO.set_dash_metadata(
- dashboard,
- data=json.loads(self._properties.get("json_metadata", "{}")),
- )
+ # Suppress autoflush during the update body so that Continuum's
+ # before_flush baseline listener does not fire mid-operation while
+ # the session is only partially populated.
+ with db.session.no_autoflush:
+ self.process_tab_diff()
+ self.process_native_filter_diff()
+
+ # Update tags
+ if (tags := self._properties.pop("tags", None)) is not None:
+ update_tags(
+ ObjectType.dashboard, self._model.id, self._model.tags,
tags
+ )
+
+ # Re-serialize position_json to escape 4-byte Unicode characters
+ if position_json := self._properties.get("position_json"):
+ self._properties["position_json"] = json.dumps(
+ json.loads(position_json)
+ )
+
+ dashboard = DashboardDAO.update(self._model, self._properties)
Review Comment:
**Suggestion:** Add an explicit type annotation to the newly introduced
local variable so it conforms to the required type-hinting rule. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new local variable `dashboard` is introduced in the updated Python code
without an explicit type annotation, and it is clearly annotatable from the
return type of `DashboardDAO.update(...)`. 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=947578e8504542fd9b1b094739c40c2e&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=947578e8504542fd9b1b094739c40c2e&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/commands/dashboard/update.py
**Line:** 86:86
**Comment:**
*Custom Rule: Add an explicit type annotation to the newly introduced
local variable so it conforms to 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%2F41176&comment_hash=db5d49b1ecaf94987f311debb55bc5b06c9086ab9ce8694527ab026ae9543e3a&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41176&comment_hash=db5d49b1ecaf94987f311debb55bc5b06c9086ab9ce8694527ab026ae9543e3a&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]