codeant-ai-for-open-source[bot] commented on code in PR #41698:
URL: https://github.com/apache/superset/pull/41698#discussion_r3572108777
##########
tests/unit_tests/mcp_service/utils/test_token_utils.py:
##########
@@ -677,3 +677,44 @@ def test_progressive_truncation(self) -> None:
assert isinstance(result, dict)
assert result["id"] == 1 # Scalar fields preserved
assert len(notes) > 0
+
+ @staticmethod
+ def _build_large_dashboard_response() -> dict[str, Any]:
+ """A dashboard with 463 charts and 48 native_filters, shared by the
+ default- and custom-max_list_items regression tests below."""
+ return {
+ "id": 1,
+ "dashboard_title": "x" * 2000, # forces Phase 2 to trigger
+ "charts": [{"id": i, "slice_name": f"chart_{i}"} for i in
range(463)],
+ "native_filters": [{"id": i, "name": f"filter_{i}"} for i in
range(48)],
+ }
+
+ def test_large_dashboard_respects_default_max_list_items(self) -> None:
+ """Regression test for the Medialab large-dashboard report.
+
+ A dashboard with 463 charts and 48 native_filters should have
+ native_filters (48 items) left untouched under the new default cap
+ of 100, while charts (463 items) is truncated to 100 โ a clear
+ improvement over the old flat 30-item cap, which truncated both.
+ """
+ response = self._build_large_dashboard_response()
+ result, was_truncated, notes = truncate_oversized_response(response,
3000)
Review Comment:
**Suggestion:** Add explicit type annotations for the newly introduced local
variables so this test block fully complies with the type-hint requirement.
[custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The added test introduces new local variables (`response`, `result`,
`was_truncated`, `notes`) that can be type-annotated, but no annotations are
present. This matches the Python type-hint requirement for newly modified code.
</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=06ab81327cc543659cb5516e25fea434&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=06ab81327cc543659cb5516e25fea434&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/utils/test_token_utils.py
**Line:** 700:701
**Comment:**
*Custom Rule: Add explicit type annotations for the newly introduced
local variables so this test block fully complies with 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%2F41698&comment_hash=620ff0425c8bc7ee2e60948d1f9c3fb61860c29d347872e37c6c296e978151c0&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41698&comment_hash=620ff0425c8bc7ee2e60948d1f9c3fb61860c29d347872e37c6c296e978151c0&reaction=dislike'>๐</a>
##########
tests/unit_tests/mcp_service/utils/test_token_utils.py:
##########
@@ -677,3 +677,44 @@ def test_progressive_truncation(self) -> None:
assert isinstance(result, dict)
assert result["id"] == 1 # Scalar fields preserved
assert len(notes) > 0
+
+ @staticmethod
+ def _build_large_dashboard_response() -> dict[str, Any]:
+ """A dashboard with 463 charts and 48 native_filters, shared by the
+ default- and custom-max_list_items regression tests below."""
+ return {
+ "id": 1,
+ "dashboard_title": "x" * 2000, # forces Phase 2 to trigger
+ "charts": [{"id": i, "slice_name": f"chart_{i}"} for i in
range(463)],
+ "native_filters": [{"id": i, "name": f"filter_{i}"} for i in
range(48)],
+ }
+
+ def test_large_dashboard_respects_default_max_list_items(self) -> None:
+ """Regression test for the Medialab large-dashboard report.
+
+ A dashboard with 463 charts and 48 native_filters should have
+ native_filters (48 items) left untouched under the new default cap
+ of 100, while charts (463 items) is truncated to 100 โ a clear
+ improvement over the old flat 30-item cap, which truncated both.
+ """
+ response = self._build_large_dashboard_response()
+ result, was_truncated, notes = truncate_oversized_response(response,
3000)
+ assert was_truncated is True
+ assert isinstance(result, dict)
+ assert len(result["charts"]) == 100
+ assert len(result["native_filters"]) == 48
+ assert any("charts" in n and "463" in n for n in notes)
+ assert not any("native_filters" in n for n in notes)
+
+ def test_large_dashboard_respects_custom_max_list_items(self) -> None:
+ """A custom max_list_items below both list sizes should truncate both
fields."""
+ response = self._build_large_dashboard_response()
+ result, was_truncated, notes = truncate_oversized_response(
+ response, 3000, max_list_items=30
+ )
Review Comment:
**Suggestion:** Type-annotate the new local variables in this custom-cap
regression test, including the unpacked return values. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new regression test declares local variables without type annotations
even though they are straightforward to annotate. This is a real omission under
the type-hint 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=fe91795cfd6a4f34ae560b8beb3ba664&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=fe91795cfd6a4f34ae560b8beb3ba664&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/utils/test_token_utils.py
**Line:** 711:714
**Comment:**
*Custom Rule: Type-annotate the new local variables in this custom-cap
regression test, including the unpacked return values.
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%2F41698&comment_hash=2861b7e39c730fec025f13346720bb12d095a0bfe1f99913395ca8d0c882861b&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41698&comment_hash=2861b7e39c730fec025f13346720bb12d095a0bfe1f99913395ca8d0c882861b&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]