codeant-ai-for-open-source[bot] commented on code in PR #40130:
URL: https://github.com/apache/superset/pull/40130#discussion_r3501609471


##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1957,17 +1974,32 @@ def test_delete_dataset_item(self):
         """
 
         dataset = self.insert_default_dataset()
+        dataset_id = dataset.id

Review Comment:
   **Suggestion:** Add an explicit scalar type annotation for this newly added 
identifier variable. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This added scalar local is an integer identifier and can be annotated 
directly. The custom type-hint rule applies to relevant variables, so the 
missing annotation is a real issue.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=bba73fa5f85048c198eff15cf41a13a9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=bba73fa5f85048c198eff15cf41a13a9&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/integration_tests/datasets/api_tests.py
   **Line:** 1977:1977
   **Comment:**
        *Custom Rule: Add an explicit scalar type annotation for this newly 
added identifier variable.
   
   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=0a5749030c9622e1c8cad93eb2e3eb8e6af2aac2d92057867e179b2e7463c74d&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=0a5749030c9622e1c8cad93eb2e3eb8e6af2aac2d92057867e179b2e7463c74d&reaction=dislike'>👎</a>



##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -191,19 +193,34 @@ def create_virtual_datasets(self):
     @pytest.fixture
     def create_datasets(self):
         with self.create_app().app_context():
+            # Purge any soft-deleted rows that occupy the unique constraint
+            stale = self.get_fixture_datasets()

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 added Python code and the local variable is inferable as a 
list of SqlaTable objects, so it can be type-annotated. The custom rule 
requires type hints on relevant variables that can be annotated, so this is a 
real violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5612cb3b57dc4d15b7dc81375df29cf9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5612cb3b57dc4d15b7dc81375df29cf9&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/integration_tests/datasets/api_tests.py
   **Line:** 197:197
   **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%2F40130&comment_hash=9e62b1025ed6f7dfa07f7408fde9cd489229df3f650a6fa095f7afd7bfc1a949&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=9e62b1025ed6f7dfa07f7408fde9cd489229df3f650a6fa095f7afd7bfc1a949&reaction=dislike'>👎</a>



##########
tests/unit_tests/commands/dataset/test_duplicate.py:
##########
@@ -101,3 +102,66 @@ def test_duplicate_dataset_access_check_passes_through() 
-> None:
                     command.validate()  # should not raise
                     # Confirm access check was called with the base dataset
                     
mock_access.assert_called_once_with(datasource=mock_dataset)
+
+
+def test_duplicate_dataset_blocked_by_soft_deleted_twin(session: Session) -> 
None:
+    """validate() rejects a duplicate whose name matches a soft-deleted
+    dataset at the same (database, schema).
+
+    The previous name-only ``find_one_or_none`` lookup ran through the
+    soft-delete visibility filter, so a soft-deleted twin was invisible and
+    the duplicate proceeded — hitting whichever DB constraint applies as an
+    opaque IntegrityError, or creating an active twin that permanently
+    blocks restore where none does. The shared ``validate_uniqueness``
+    check bypasses the filter and refuses with a clean validation error.
+    """
+    from datetime import datetime, timezone
+
+    from superset import db
+    from superset.commands.dataset.duplicate import DuplicateDatasetCommand
+    from superset.commands.dataset.exceptions import DatasetInvalidError
+    from superset.connectors.sqla.models import SqlaTable
+    from superset.models.core import Database
+
+    SqlaTable.metadata.create_all(session.get_bind())
+
+    database = Database(database_name="dup_db", sqlalchemy_uri="sqlite://")
+    base = SqlaTable(
+        table_name="base_view",
+        schema="main",
+        database=database,
+        sql="select 1",
+    )
+    hidden_twin = SqlaTable(
+        table_name="dup_name",
+        schema="main",
+        database=database,
+        deleted_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+    )
+    db.session.add_all([database, base, hidden_twin])
+    db.session.flush()
+
+    with (
+        # find_by_id applies the security base filter, which needs a request
+        # user; return the seeded row directly. validate_uniqueness — the
+        # behaviour under test — runs for real against the session.
+        patch(
+            "superset.commands.dataset.duplicate.DatasetDAO.find_by_id",
+            return_value=base,
+        ),
+        
patch("superset.commands.dataset.duplicate.security_manager.raise_for_access"),
+        patch(
+            "superset.commands.dataset.duplicate."
+            "DuplicateDatasetCommand.populate_owners",
+            return_value=[],
+        ),
+    ):
+        command = DuplicateDatasetCommand(
+            {
+                "base_model_id": base.id,
+                "table_name": "dup_name",
+                "is_managed_externally": False,
+            }
+        )

Review Comment:
   **Suggestion:** Add an explicit type annotation for this newly introduced 
command variable. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new command variable is a relevant local variable in Python code and it 
does not include an explicit type hint.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4b8ad907bf01474191e2ca9399d22afb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4b8ad907bf01474191e2ca9399d22afb&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/commands/dataset/test_duplicate.py
   **Line:** 159:165
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this newly introduced 
command variable.
   
   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=42e6cb3045a57af6d90724b5ca9ff67063e0cd383eb9a5d154d6e085e11e57e3&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=42e6cb3045a57af6d90724b5ca9ff67063e0cd383eb9a5d154d6e085e11e57e3&reaction=dislike'>👎</a>



##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -191,19 +193,34 @@ def create_virtual_datasets(self):
     @pytest.fixture
     def create_datasets(self):
         with self.create_app().app_context():
+            # Purge any soft-deleted rows that occupy the unique constraint
+            stale = self.get_fixture_datasets()
+            for ds in stale:
+                db.session.delete(ds)
+            if stale:
+                db.session.commit()
+
             datasets = []
             admin = self.get_user("admin")
             main_db = get_main_database()
             for tables_name in self.fixture_tables_names:
                 datasets.append(self.insert_dataset(tables_name, [admin.id], 
main_db))
 
+            # Capture IDs eagerly — dataset objects may be detached after yield
+            dataset_ids = [ds.id for ds in datasets]

Review Comment:
   **Suggestion:** Add a concrete list type annotation for this new variable so 
its element type is explicit. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly added local list is clearly typed as a list of integers, so a 
concrete annotation is possible. Because the rule flags omitted type hints on 
relevant variables, this is a verified violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=62002cd46d8e43748df8aa31ffe2c819&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=62002cd46d8e43748df8aa31ffe2c819&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/integration_tests/datasets/api_tests.py
   **Line:** 210:210
   **Comment:**
        *Custom Rule: Add a concrete list type annotation for this new variable 
so its 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%2F40130&comment_hash=522847e630c94b0b65c17646bb2dce6cd994c1aa611385a52c9148c31e643e68&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=522847e630c94b0b65c17646bb2dce6cd994c1aa611385a52c9148c31e643e68&reaction=dislike'>👎</a>



##########
tests/unit_tests/commands/dataset/restore_test.py:
##########
@@ -0,0 +1,172 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Unit tests for RestoreDatasetCommand."""
+
+from __future__ import annotations
+
+import uuid
+from datetime import datetime, timezone
+from unittest.mock import MagicMock, patch
+
+import pytest
+
+# Stable UUIDs make the test boundary realistic: the production command
+# loads by UUID, not integer ID. The test only mocks the DAO lookup, but
+# the argument shape should still match.
+_DATASET_UUID = str(uuid.uuid4())
+_MISSING_UUID = str(uuid.uuid4())
+
+
+def test_restore_dataset_clears_deleted_at(app_context: None) -> None:
+    """RestoreDatasetCommand.run() restores a soft-deleted dataset."""
+    from superset.commands.dataset.restore import RestoreDatasetCommand
+
+    dataset = MagicMock()
+    dataset.deleted_at = datetime(2026, 1, 1, tzinfo=timezone.utc)

Review Comment:
   **Suggestion:** Provide a type annotation for this mock variable declaration 
to comply with the rule requiring hints on relevant annotatable variables. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This local variable is newly introduced and is annotatable, but it has no 
type hint. That fits the custom Python type-hint rule.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=802c0e5e77e8422089a63dca1cdbd76d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=802c0e5e77e8422089a63dca1cdbd76d&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/commands/dataset/restore_test.py
   **Line:** 39:39
   **Comment:**
        *Custom Rule: Provide a type annotation for this mock variable 
declaration to comply with the rule requiring hints on relevant annotatable 
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=5833126bd57ffd925e56e9c7c97ac1f65040e7046d19b4df14b3e8684f505e3b&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=5833126bd57ffd925e56e9c7c97ac1f65040e7046d19b4df14b3e8684f505e3b&reaction=dislike'>👎</a>



##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1957,17 +1974,32 @@ def test_delete_dataset_item(self):
         """
 
         dataset = self.insert_default_dataset()
+        dataset_id = dataset.id
         view_menu = security_manager.find_view_menu(dataset.get_perm())
         assert view_menu is not None
         view_menu_id = view_menu.id
         self.login(ADMIN_USERNAME)
         uri = f"api/v1/dataset/{dataset.id}"
         rv = self.client.delete(uri)
         assert rv.status_code == 200
+        # With soft delete, the row still exists (with deleted_at set) so
+        # FAB permissions are preserved for potential restore.
         non_view_menu = db.session.query(security_manager.viewmenu_model).get(
             view_menu_id
         )
-        assert non_view_menu is None
+        assert non_view_menu is not None
+
+        # Hard-delete the soft-deleted row to avoid unique constraint
+        # collisions in subsequent tests
+        row = (
+            db.session.query(SqlaTable)
+            .execution_options(**{SKIP_VISIBILITY_FILTER_CLASSES: {SqlaTable}})
+            .filter(SqlaTable.id == dataset_id)
+            .one_or_none()
+        )

Review Comment:
   **Suggestion:** Annotate this new query result variable with an optional 
model type to comply with type-hinting requirements. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is newly added Python code and the query result is an optional 
SqlaTable value, which can be annotated. Since the rule requires type hints for 
relevant variables that can be annotated, this omission is verified.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7b7eb039191c471dbf466dcda157a61b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7b7eb039191c471dbf466dcda157a61b&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/integration_tests/datasets/api_tests.py
   **Line:** 1994:1999
   **Comment:**
        *Custom Rule: Annotate this new query result variable with an optional 
model type to comply with type-hinting requirements.
   
   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=64e03b003b3ad9f8b79ded6b82e610dca843a81bb7d16711f065423b9025550e&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=64e03b003b3ad9f8b79ded6b82e610dca843a81bb7d16711f065423b9025550e&reaction=dislike'>👎</a>



##########
superset/commands/database/exceptions.py:
##########
@@ -156,6 +156,18 @@ 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 or permanently purge them first."
+    )

Review Comment:
   **Suggestion:** Add an explicit type annotation to the new class-level 
message attribute. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new class-level `message` attribute is a relevant variable that can be 
annotated, and it is introduced without a type hint. This matches the Python 
type-hinting rule for newly added code.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b5dfafd712494dfdbf0f5bcf89d7ea10&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b5dfafd712494dfdbf0f5bcf89d7ea10&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:** 165:168
   **Comment:**
        *Custom Rule: Add an explicit type annotation to the new class-level 
message attribute.
   
   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=f5b292e538e5f92d4d9aa291bbbf108de83331e0b167f03ca28c811b67da8850&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=f5b292e538e5f92d4d9aa291bbbf108de83331e0b167f03ca28c811b67da8850&reaction=dislike'>👎</a>



##########
superset/datasets/filters.py:
##########
@@ -51,3 +57,40 @@ def apply(self, query: Query, value: bool) -> Query:
                 )
             )
         return query
+
+
+class DatasetDeletedStateFilter(  # pylint: disable=too-few-public-methods
+    BaseDeletedStateFilter
+):
+    """Rison filter for the GET list that exposes soft-deleted datasets.
+
+    Soft-deleted rows are additionally scoped to the **restore audience**: only
+    the dataset's owners (or admins) may enumerate them. This mirrors
+    ``RestoreDatasetCommand``'s ``raise_for_ownership`` check, so a read-access
+    non-owner (who can see the dataset via ``datasource_access``) cannot list
+    soft-deleted datasets they could never restore. Live rows are unaffected —
+    they keep their normal ``DatasourceFilter`` visibility. The ownership
+    scoping is part of the cross-entity deleted-state contract: only the
+    restore audience may enumerate soft-deleted rows (kept consistent with the
+    deleted-state filters in the dashboard and chart soft-delete rollouts).
+    """
+
+    arg_name = "dataset_deleted_state"

Review Comment:
   **Suggestion:** Add an explicit type annotation for this class-level 
attribute to satisfy the type-hint requirement for relevant variables. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The custom rule requires type hints for relevant variables that can be 
annotated. This class-level string attribute is newly introduced and could be 
annotated as a class variable, but it is left untyped, so the suggestion 
identifies a real violation.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e246e1ebee174b6781bb4ddc158ac94e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e246e1ebee174b6781bb4ddc158ac94e&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/datasets/filters.py
   **Line:** 78:78
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this class-level 
attribute to satisfy the type-hint requirement 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%2F40130&comment_hash=2d2c68c8403992d9d3b9ed510bdd5412b29c01cd620c4f8e7b358f5f61b45f23&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=2d2c68c8403992d9d3b9ed510bdd5412b29c01cd620c4f8e7b358f5f61b45f23&reaction=dislike'>👎</a>



##########
superset/datasets/filters.py:
##########
@@ -51,3 +57,40 @@ def apply(self, query: Query, value: bool) -> Query:
                 )
             )
         return query
+
+
+class DatasetDeletedStateFilter(  # pylint: disable=too-few-public-methods
+    BaseDeletedStateFilter
+):
+    """Rison filter for the GET list that exposes soft-deleted datasets.
+
+    Soft-deleted rows are additionally scoped to the **restore audience**: only
+    the dataset's owners (or admins) may enumerate them. This mirrors
+    ``RestoreDatasetCommand``'s ``raise_for_ownership`` check, so a read-access
+    non-owner (who can see the dataset via ``datasource_access``) cannot list
+    soft-deleted datasets they could never restore. Live rows are unaffected —
+    they keep their normal ``DatasourceFilter`` visibility. The ownership
+    scoping is part of the cross-entity deleted-state contract: only the
+    restore audience may enumerate soft-deleted rows (kept consistent with the
+    deleted-state filters in the dashboard and chart soft-delete rollouts).
+    """
+
+    arg_name = "dataset_deleted_state"
+    model = SqlaTable

Review Comment:
   **Suggestion:** Add a concrete type annotation for this class-level model 
reference instead of leaving it unannotated. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added class attribute whose type is clear and annotatable, 
but it is left untyped. That matches the type-hint requirement for relevant 
variables, so the suggestion is verified.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0ebf35766ace4f5089bca84240db27b5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0ebf35766ace4f5089bca84240db27b5&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/datasets/filters.py
   **Line:** 79:79
   **Comment:**
        *Custom Rule: Add a concrete type annotation for this class-level model 
reference instead of leaving it unannotated.
   
   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=5462481758bb5af4ad348427716a6378f05c8a619b9447785c407ec47aff90b0&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40130&comment_hash=5462481758bb5af4ad348427716a6378f05c8a619b9447785c407ec47aff90b0&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]

Reply via email to