codeant-ai-for-open-source[bot] commented on code in PR #40130:
URL: https://github.com/apache/superset/pull/40130#discussion_r3530097204
##########
superset/commands/database/exceptions.py:
##########
@@ -156,6 +178,21 @@ class
DatabaseDeleteDatasetsExistFailedError(DeleteFailedError):
message = _("Cannot delete a database that has datasets attached")
+class DatabaseDeleteSoftDeletedDatasetsExistFailedError(
+ DatabaseDeleteDatasetsExistFailedError
+):
+ # Subclasses the live-datasets error so the existing API handler catches
+ # both; only the message differs, telling the operator that the blockers
+ # are hidden (soft-deleted) rows even though their dataset list looks
empty.
+ message = _(
+ "Cannot delete a database whose only remaining datasets are "
+ "soft-deleted. Restore them (POST /api/v1/dataset/<uuid>/restore) "
+ "and delete them permanently once a purge capability ships, or "
+ "remove the underlying rows out-of-band, before deleting the "
+ "database."
+ )
Review Comment:
**Suggestion:** Add an explicit type annotation for the new class-level
`message` attribute so newly introduced variables in modified Python code
remain type-hinted. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new class introduces a class-level `message` attribute without a type
annotation. Since the custom rule requires type hints on newly added Python
variables that can be annotated, this is a real rule violation in the modified
code.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7797f17c161c415fb3448505e87d44ec&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=7797f17c161c415fb3448505e87d44ec&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/database/exceptions.py
**Line:** 187:193
**Comment:**
*Custom Rule: Add an explicit type annotation for the new class-level
`message` attribute so newly introduced variables in modified Python code
remain 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%2F40130&comment_hash=2ebf6014d4fc16451198ed4225974d360ef2f5e9c1a9f40119829db4b8975f70&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=2ebf6014d4fc16451198ed4225974d360ef2f5e9c1a9f40119829db4b8975f70&reaction=dislike'>👎</a>
##########
superset/views/base.py:
##########
@@ -769,7 +770,23 @@ def apply(self, query: Query, value: Any) -> Query:
models.Database,
models.Database.id == self.model.database_id,
)
- return query.filter(get_dataset_access_filters(self.model))
+ access_filter = get_dataset_access_filters(self.model)
+ # Owners keep sight of their own soft-deleted rows regardless of
+ # datasource grants: ``raise_for_access`` counts ownership as
+ # datasource access, and the restore audience is owners/admins.
+ # The leg is inert for live rows (``deleted_at IS NULL`` fails it)
+ # and only ever matters when a deleted-state rison filter has opted
+ # the request in to seeing soft-deleted rows — without that session
+ # bypass, no soft-deleted row reaches this query at all.
+ deleted_at = getattr(self.model, "deleted_at", None)
+ owners = getattr(self.model, "owners", None)
+ if deleted_at is not None and owners is not None:
+ owned_trash = and_(
+ deleted_at.is_not(None),
+ owners.any(security_manager.user_model.id ==
utils.get_user_id()),
Review Comment:
**Suggestion:** Add explicit type annotations for the newly introduced local
SQLAlchemy expression variables to satisfy the type-hint requirement for
relevant new variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The new code introduces several local variables without type annotations in
a Python file. This matches the rule requiring type hints for newly added
relevant variables that can be annotated, so the suggestion is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=84f88e930c3f4d5cabacdd02ff351aac&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=84f88e930c3f4d5cabacdd02ff351aac&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/views/base.py
**Line:** 773:786
**Comment:**
*Custom Rule: Add explicit type annotations for the newly introduced
local SQLAlchemy expression variables to satisfy the type-hint requirement for
relevant new 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%2F40130&comment_hash=9e1e3726c6591e7bafb67e928fe04d7657aaa7736b377e845ada622b8898c200&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=9e1e3726c6591e7bafb67e928fe04d7657aaa7736b377e845ada622b8898c200&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]