codeant-ai-for-open-source[bot] commented on code in PR #41855: URL: https://github.com/apache/superset/pull/41855#discussion_r3565413121
########## tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py: ########## @@ -0,0 +1,131 @@ +# 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 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) Review Comment: **Suggestion:** Add an explicit return type annotation to this fixture function (for example an iterator/generator-based fixture return type) to satisfy the required type-hint rule. [custom_rule] **Severity Level:** Minor ๐งน <details> <summary><b>Why it matters? โญ </b></summary> The new fixture function `mock_auth` is introduced without any return type annotation, which matches the rule requiring type hints on new or modified Python functions where applicable. </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=8f8f4fec092647b2971457844f7835a6&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=8f8f4fec092647b2971457844f7835a6&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:** 44:44 **Comment:** *Custom Rule: Add an explicit return type annotation to this fixture function (for example an iterator/generator-based fixture return type) to satisfy the required type-hint 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=ed6a01aaf1b2005af5aa02b765916aa84cf8c66ec7dfe22ca46cb215e0fd3f11&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=ed6a01aaf1b2005af5aa02b765916aa84cf8c66ec7dfe22ca46cb215e0fd3f11&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() Review Comment: **Suggestion:** Add an explicit type annotation for this mock variable to comply with the type-hint requirement for new code. [custom_rule] **Severity Level:** Minor ๐งน <details> <summary><b>Why it matters? โญ </b></summary> This is new Python code in the test file and the local variable can be annotated, so it matches the type-hint rule for newly added code that omits an available type hint. </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=a5411b43c37544a28f10915bd5191acb&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=a5411b43c37544a28f10915bd5191acb&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:** 325:325 **Comment:** *Custom Rule: Add an explicit type annotation for this mock variable to comply with the type-hint requirement for new code. 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=81fd4bd402457a2fadc59095d498285c82878a136452f45498534ccb81d4a0f3&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=81fd4bd402457a2fadc59095d498285c82878a136452f45498534ccb81d4a0f3&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 a concrete type annotation for this bound filter variable so the new test code remains fully typed. [custom_rule] **Severity Level:** Minor ๐งน <details> <summary><b>Why it matters? โญ </b></summary> This is a newly added local variable in Python code and it could be annotated with its concrete type, so the omission of a type hint is a real match for the rule. </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=1955fd5970954c14b57120b124219b39&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=1955fd5970954c14b57120b124219b39&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:** 327:327 **Comment:** *Custom Rule: Add a concrete type annotation for this bound filter variable so the new test code remains fully typed. 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=a15ede5d4ec0690d7ea5ba682b5db3c15e49ea480c9a06a8a985c2b8f996c5b9&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=a15ede5d4ec0690d7ea5ba682b5db3c15e49ea480c9a06a8a985c2b8f996c5b9&reaction=dislike'>๐</a> ########## tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py: ########## @@ -0,0 +1,170 @@ +# 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_charts ``deleted_state`` trash listing. + +The deleted_state param opts the list query into surfacing soft-deleted +charts: the session-scoped visibility bypass wraps the DAO call, the REST +``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is +passed through as a DAO custom filter, and ``deleted_at`` is forced into the +loaded columns so trashed rows are distinguishable in the response. +""" + +from datetime import datetime +from unittest.mock import MagicMock, Mock, patch +from uuid import UUID + +import pytest +from fastmcp import Client +from fastmcp.exceptions import ToolError + +from superset.mcp_service.app import mcp +from superset.utils import json + +_DAO_LIST = "superset.daos.chart.ChartDAO.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(): Review Comment: **Suggestion:** Add an explicit return type hint to this fixture function (for example, an iterator/generator of the mocked auth object) so it complies with the required typing rule. [custom_rule] **Severity Level:** Minor ๐งน <details> <summary><b>Why it matters? โญ </b></summary> The fixture function `mock_auth` has no return type annotation, and the custom rule requires new or modified Python functions to include type hints when they can be annotated. This is a real violation in the added test file. </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=286c7d777b324f419faa18c1e4620771&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=286c7d777b324f419faa18c1e4620771&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/chart/tool/test_list_charts_deleted_state.py **Line:** 48:48 **Comment:** *Custom Rule: Add an explicit return type hint to this fixture function (for example, an iterator/generator of the mocked auth object) so it complies with the required typing 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=700dd03823731a60510732babb002748f15fcf697f552a4894e05f9cfa04ed91&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=700dd03823731a60510732babb002748f15fcf697f552a4894e05f9cfa04ed91&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]
