Skip to content

refactor(api): remove safe type ignores from MCP tests#36193

Open
Dawn-Fighter wants to merge 2 commits into
langgenius:mainfrom
Dawn-Fighter:refactor/mcp-type-ignore-tests
Open

refactor(api): remove safe type ignores from MCP tests#36193
Dawn-Fighter wants to merge 2 commits into
langgenius:mainfrom
Dawn-Fighter:refactor/mcp-type-ignore-tests

Conversation

@Dawn-Fighter
Copy link
Copy Markdown

Summary

  • Removes safe # type: ignore comments from MCP type tests by using typed capability models and explicit narrowing.
  • Keeps runtime assertions equivalent while making extra-field checks use Pydantic model_extra.

Related Issue

Verification

  • uv run --project api --with ruff ruff check api/tests/unit_tests/core/mcp/test_types.py
  • uv run --project api pytest -o addopts='' api/tests/unit_tests/core/mcp/test_types.py
  • uv run --project api pyright api/tests/unit_tests/core/mcp/test_types.py

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-15 03:39:22.429943386 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-15 03:39:15.395900671 +0000
@@ -4104,14 +4104,6 @@
    --> tests/unit_tests/core/mcp/session/test_client_session.py:557:12
 ERROR Object of class `ListRootsResult` has no attribute `message` [missing-attribute]
    --> tests/unit_tests/core/mcp/session/test_client_session.py:558:31
-ERROR Object of class `NoneType` has no attribute `idempotentHint` [missing-attribute]
-   --> tests/unit_tests/core/mcp/test_types.py:254:16
-ERROR `in` is not supported between `Literal['authorization_code']` and `None` [not-iterable]
-   --> tests/unit_tests/core/mcp/test_types.py:335:16
-ERROR `in` is not supported between `Literal['S256']` and `None` [not-iterable]
-   --> tests/unit_tests/core/mcp/test_types.py:380:16
-ERROR Argument `Literal['1.0']` is not assignable to parameter `jsonrpc` with type `Literal['2.0']` in function `core.mcp.types.JSONRPCRequest.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/mcp/test_types.py:458:25
 ERROR Argument `_FakeModelRuntime` is not assignable to parameter `runtime` with type `ModelRuntime` in function `core.plugin.impl.model_runtime_factory.create_model_type_instance` [bad-argument-type]
    --> tests/unit_tests/core/model_runtime/test_model_provider_factory.py:401:17
 ERROR Argument `_FakeModelRuntime` is not assignable to parameter `runtime` with type `ModelRuntime` in function `core.plugin.impl.model_runtime_factory.create_model_type_instance` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.69% +43.69%
Strict coverage 0.00% 43.22% +43.22%
Typed symbols 0 22,072 +22,072
Untyped symbols 0 28,758 +28,758
Modules 0 2554 +2,554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant