codeant-ai-for-open-source[bot] commented on code in PR #41530:
URL: https://github.com/apache/superset/pull/41530#discussion_r3493571969
##########
superset/cli/thumbnails.py:
##########
@@ -82,18 +82,21 @@ def compute_generic_thumbnail(
query = db.session.query(model_cls)
if model_ids:
query = query.filter(model_cls.id.in_(model_ids))
- dashboards = query.all()
- count = len(dashboards)
- for i, model in enumerate(dashboards):
- if asynchronous:
- func = compute_func.delay
- action = "Triggering"
- else:
- func = compute_func
- action = "Processing"
- msg = f'{action} {friendly_type} "{model}" ({i + 1}/{count})'
+ # Materialize the id and label up front. Computing a thumbnail below
can
+ # close/expire the session, which detaches the ORM instances and makes
+ # str(model) raise DetachedInstanceError on subsequent iterations.
+ items = [(model.id, str(model)) for model in query.all()]
+ count = len(items)
+ if asynchronous:
+ func = compute_func.delay
+ action = "Triggering"
+ else:
+ func = compute_func
+ action = "Processing"
Review Comment:
**Suggestion:** Add explicit type annotations for the newly introduced local
variables to comply with the type-hinting requirement. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The added local variables `items`, `count`, `func`, and `action` are all
inferred from context and can be explicitly annotated, so this matches the
type-hinting rule for newly introduced Python code without type hints.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b6a11c4d9567455e9dc0d462686e1e7e&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=b6a11c4d9567455e9dc0d462686e1e7e&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/thumbnails.py
**Line:** 88:95
**Comment:**
*Custom Rule: Add explicit type annotations for the newly introduced
local variables to comply with the 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%2F41530&comment_hash=a8157171f6d45b8c7b0040aec26bb50438cc80cff749c3c4e92b908d99d1bcda&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41530&comment_hash=a8157171f6d45b8c7b0040aec26bb50438cc80cff749c3c4e92b908d99d1bcda&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]