codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3537879790
##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
self._validate_order_column(order_column)
+ deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+ if deleted_state_bound is not None:
+ # Trashed rows must be distinguishable from live ones (matters in
+ # "include" mode), so force deleted_at into the loaded columns
+ # and the serialization allowlist.
+ for column_list in (columns_requested, columns_to_load):
+ if "deleted_at" not in column_list:
+ column_list.append("deleted_at")
+
# Query the DAO
items: List[Any]
- items, total_count = self._call_dao_list(
- filters=filters,
- order_column=order_column or "changed_on",
- order_direction=str(order_direction or "desc"),
- page=page,
- page_size=page_size,
- search=search,
- columns_to_load=columns_to_load,
- )
+ dao_kwargs = {
+ "filters": filters,
+ "order_column": order_column or "changed_on",
+ "order_direction": str(order_direction or "desc"),
+ "page": page,
+ "page_size": page_size,
+ "search": search,
+ "columns_to_load": columns_to_load,
+ }
Review Comment:
**Suggestion:** Add an explicit type annotation to this dictionary to
satisfy the type-hint requirement for relevant local variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly introduced local dictionary in Python code and it has no
explicit type annotation. That matches the rule requiring type hints for
relevant variables that can be annotated, so the suggestion is valid.
</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=77966dcec1c44087b9824bad88cdd42d&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=77966dcec1c44087b9824bad88cdd42d&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/mcp_service/mcp_core.py
**Line:** 395:403
**Comment:**
*Custom Rule: Add an explicit type annotation to this dictionary to
satisfy the type-hint requirement for relevant local 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%2F41855&comment_hash=437f04b212220406ccb563500c048b742b768f105d473ac02178b3ff1db39d8c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=437f04b212220406ccb563500c048b742b768f105d473ac02178b3ff1db39d8c&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)
Review Comment:
**Suggestion:** Add an explicit return type hint to this fixture function
(for example, a generator/yield-compatible return annotation) to satisfy
required Python typing. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The rule requires new or modified Python functions to include type hints
when they can be annotated. This fixture function is defined without any return
type annotation, so the suggestion correctly identifies a real violation.
</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=fe44ee9552824ba39e0fd166081d19a0&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=fe44ee9552824ba39e0fd166081d19a0&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:** 47:47
**Comment:**
*Custom Rule: Add an explicit return type hint to this fixture function
(for example, a generator/yield-compatible return annotation) to satisfy
required Python typing.
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=b6db9934ab24d450c41c03a3bd9f7b6801378bdda36acc36b45d8355fc6e41dc&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=b6db9934ab24d450c41c03a3bd9f7b6801378bdda36acc36b45d8355fc6e41dc&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]