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


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# 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 list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"

Review Comment:
   **Suggestion:** Add an explicit type annotation for this module-level 
constant (preferably as an immutable string constant) to satisfy the type-hint 
requirement. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This new module-level constant is a Python variable that can be annotated, 
and it currently omits a type hint. That matches the type-hint requirement for 
new or modified Python code.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=ea03c73a90a44a278dcb6dec5571eb37&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=ea03c73a90a44a278dcb6dec5571eb37&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/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 36:36
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this module-level 
constant (preferably as an immutable string constant) 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%2F41855&comment_hash=34d6cc092fad0eee4de4a9ee460883031dab82a9a3347167f9132779e6ccd987&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=34d6cc092fad0eee4de4a9ee460883031dab82a9a3347167f9132779e6ccd987&reaction=dislike'>๐Ÿ‘Ž</a>



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# 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 list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
[email protected]
+def mcp_server() -> object:
+    return mcp
+
+
[email protected](autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as 
mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
[email protected]
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
[email protected]
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
[email protected]
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)

Review Comment:
   **Suggestion:** Add a concrete type annotation for the parsed JSON payload 
variable so the structure is explicit and type-checked. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The variable is introduced in new Python code and holds parsed JSON data, so 
it is a relevant local variable that could be annotated. Since it currently has 
no type hint, it fits the type-hint rule.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=0396b1a27a5642c88b0776e0c88fbbb0&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=0396b1a27a5642c88b0776e0c88fbbb0&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/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 129:129
   **Comment:**
        *Custom Rule: Add a concrete type annotation for the parsed JSON 
payload variable so the structure is explicit and type-checked.
   
   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%2F41855&comment_hash=fb890446681c6cdcf05881e645fd52e8c030944cb7df69f637bbe035a23a1c1e&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=fb890446681c6cdcf05881e645fd52e8c030944cb7df69f637bbe035a23a1c1e&reaction=dislike'>๐Ÿ‘Ž</a>



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() 
-> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> 
None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value โ€” BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   **Suggestion:** Add explicit type annotations for the newly introduced local 
variables so the test fully complies with the type-hinting rule. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The added test introduces local variables `inner` and `bound` without type 
annotations. The custom rule requires type hints for new or modified Python 
code where variables can be annotated, so this is a real violation.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </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=f69c07a4e4bc4d2685deec1f2099559c&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=f69c07a4e4bc4d2685deec1f2099559c&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/mcp_service/test_mcp_core.py
   **Line:** 321:327
   **Comment:**
        *Custom Rule: Add explicit type annotations for the newly introduced 
local variables so the test fully complies with the 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%2F41855&comment_hash=3d98f4ccaa6f77959bf74636fce9041291cde753847c83d0677219059f22d64d&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=3d98f4ccaa6f77959bf74636fce9041291cde753847c83d0677219059f22d64d&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