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


##########
tests/unit_tests/mcp_service/test_mcp_server.py:
##########
@@ -162,6 +162,61 @@ def 
test_create_event_store_returns_none_when_redis_store_fails():
         assert result is None
 
 
[email protected]
+async def test_register_health_endpoint_registers_get_health() -> None:
+    """/health is registered as an HTTP GET custom route on the MCP 
instance."""
+    from superset.mcp_service.server import _register_health_endpoint
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this nested 
function instead of suppressing untyped-definition checks. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The nested function lacks a return type annotation and is explicitly 
suppressing the untyped-definition check, which matches the rule requiring type 
hints on new or modified Python functions.
   </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=5f9ed85acc2d4e36bdaecfb06123b235&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=5f9ed85acc2d4e36bdaecfb06123b235&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_server.py
   **Line:** 172:172
   **Comment:**
        *Custom Rule: Add an explicit return type annotation to this nested 
function instead of suppressing untyped-definition checks.
   
   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%2F41755&comment_hash=5ce0c3891626bf6631e45d5712ee53a2299bf56d47a8fc8425e13ecd765b4877&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41755&comment_hash=5ce0c3891626bf6631e45d5712ee53a2299bf56d47a8fc8425e13ecd765b4877&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_server.py:
##########
@@ -162,6 +162,61 @@ def 
test_create_event_store_returns_none_when_redis_store_fails():
         assert result is None
 
 
[email protected]
+async def test_register_health_endpoint_registers_get_health() -> None:
+    """/health is registered as an HTTP GET custom route on the MCP 
instance."""
+    from superset.mcp_service.server import _register_health_endpoint
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]
+        captured["path"] = path
+        captured["methods"] = methods
+
+        def decorator(fn):  # type: ignore[no-untyped-def]
+            captured["fn"] = fn
+            return fn
+
+        return decorator
+
+    mcp_instance = MagicMock()
+    mcp_instance.custom_route = custom_route
+
+    _register_health_endpoint(mcp_instance)
+
+    assert captured["path"] == "/health"
+    assert captured["methods"] == ["GET"]
+
+
[email protected]
+async def test_health_endpoint_returns_ok() -> None:
+    """The /health handler returns 200 with a JSON status body."""
+    from starlette.requests import Request
+
+    from superset.mcp_service.server import _register_health_endpoint
+    from superset.utils import json
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]

Review Comment:
   **Suggestion:** Add a concrete return type annotation for this nested 
function and remove the untyped-definition suppression. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The function is missing a return type annotation and uses a no-untyped-def 
ignore, so the suggestion correctly identifies an actual type-hint omission in 
the modified Python 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=961e550bd98340568e21e2089a982a4e&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=961e550bd98340568e21e2089a982a4e&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_server.py
   **Line:** 201:201
   **Comment:**
        *Custom Rule: Add a concrete return type annotation for this nested 
function and remove the untyped-definition suppression.
   
   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%2F41755&comment_hash=e09801bd9211370b943feae3b58a7f2e571ba9651660426fc1de10c6f99c5b9c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41755&comment_hash=e09801bd9211370b943feae3b58a7f2e571ba9651660426fc1de10c6f99c5b9c&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_server.py:
##########
@@ -162,6 +162,61 @@ def 
test_create_event_store_returns_none_when_redis_store_fails():
         assert result is None
 
 
[email protected]
+async def test_register_health_endpoint_registers_get_health() -> None:
+    """/health is registered as an HTTP GET custom route on the MCP 
instance."""
+    from superset.mcp_service.server import _register_health_endpoint
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]
+        captured["path"] = path
+        captured["methods"] = methods
+
+        def decorator(fn):  # type: ignore[no-untyped-def]

Review Comment:
   **Suggestion:** Annotate the callback parameter and return type for this 
nested decorator function rather than bypassing typing with an ignore. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This nested decorator parameter and its return type are unannotated, and the 
code suppresses the type checker instead of adding hints, which violates the 
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=48656991ea484e9cb7babcdcb568e362&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=48656991ea484e9cb7babcdcb568e362&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_server.py
   **Line:** 176:176
   **Comment:**
        *Custom Rule: Annotate the callback parameter and return type for this 
nested decorator function rather than bypassing typing with an ignore.
   
   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%2F41755&comment_hash=83260dacbed228bec66490ffc4c91f96b62b124c690116d5dd833e0f7759933b&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41755&comment_hash=83260dacbed228bec66490ffc4c91f96b62b124c690116d5dd833e0f7759933b&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_server.py:
##########
@@ -162,6 +162,61 @@ def 
test_create_event_store_returns_none_when_redis_store_fails():
         assert result is None
 
 
[email protected]
+async def test_register_health_endpoint_registers_get_health() -> None:
+    """/health is registered as an HTTP GET custom route on the MCP 
instance."""
+    from superset.mcp_service.server import _register_health_endpoint
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]
+        captured["path"] = path
+        captured["methods"] = methods
+
+        def decorator(fn):  # type: ignore[no-untyped-def]
+            captured["fn"] = fn
+            return fn
+
+        return decorator
+
+    mcp_instance = MagicMock()
+    mcp_instance.custom_route = custom_route
+
+    _register_health_endpoint(mcp_instance)
+
+    assert captured["path"] == "/health"
+    assert captured["methods"] == ["GET"]
+
+
[email protected]
+async def test_health_endpoint_returns_ok() -> None:
+    """The /health handler returns 200 with a JSON status body."""
+    from starlette.requests import Request
+
+    from superset.mcp_service.server import _register_health_endpoint
+    from superset.utils import json
+
+    captured: dict[str, object] = {}
+
+    def custom_route(path: str, methods: list[str]):  # type: 
ignore[no-untyped-def]
+        def decorator(fn):  # type: ignore[no-untyped-def]

Review Comment:
   **Suggestion:** Type-annotate both the function argument and return value 
for this decorator wrapper instead of leaving it untyped. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The decorator wrapper leaves both the argument type and return type 
unannotated, and the ignore confirms the omission rather than fixing it, so 
this is a real type-hint 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=4936f59712154aefadadb4357fb93642&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=4936f59712154aefadadb4357fb93642&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_server.py
   **Line:** 202:202
   **Comment:**
        *Custom Rule: Type-annotate both the function argument and return value 
for this decorator wrapper instead of leaving it untyped.
   
   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%2F41755&comment_hash=6df976455a50c71b8e194ba780d5c96733190176e9b2314f52edc10625fd69c9&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41755&comment_hash=6df976455a50c71b8e194ba780d5c96733190176e9b2314f52edc10625fd69c9&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