Skip to content

Commit 2a13e6d

Browse files
committed
Keep the Client type-hints test green on Python 3.10
typing.get_type_hints(Client) raises TypeError on CPython 3.10 for any dataclass using KW_ONLY (a stdlib bug fixed in 3.11), which has nothing to do with the SDK and turned the test red on the 3.10 CI cells. Probe Client.__init__ instead: it evaluates the same qualified mcp.server annotation on every supported version.
1 parent ff6c36e commit 2a13e6d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎tests/client/test_client.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,12 @@ def test_client_with_url_initializes_streamable_http_transport():
406406

407407

408408
def test_client_annotations_still_evaluate_at_runtime():
409-
"""SDK-defined: `typing.get_type_hints(Client)` resolves even though the server stack is
410-
a typing-only import in the client module; the `server` annotation is qualified through
411-
the lazy `mcp.server` namespace, which imports it only when the hints are evaluated."""
412-
hints = typing.get_type_hints(Client)
409+
"""SDK-defined: `typing.get_type_hints` on `Client` resolves even though the server stack
410+
is a typing-only import in the client module; the `server` annotation is qualified
411+
through the lazy `mcp.server` namespace, which imports it only when the hints are
412+
evaluated. Probed via `__init__` because class-level `get_type_hints(Client)` trips a
413+
CPython 3.10 bug with `KW_ONLY` dataclasses (fixed in 3.11), unrelated to the SDK."""
414+
hints = typing.get_type_hints(Client.__init__)
413415
server_targets = typing.get_args(hints["server"])
414416
assert MCPServer in server_targets
415417
assert str in server_targets

0 commit comments

Comments
 (0)