Skip to content

Commit 95304e4

Browse files
Add missing type annotations to test functions
Restore type annotations on test function parameters in test_streamable_http.py that were accidentally removed during the function renaming from streamablehttp_client to streamable_http_client. Added type annotations to: - Fixture parameters: basic_server, basic_server_url, json_response_server, json_server_url, event_server, monkeypatch - Test function parameters: initialized_client_session This fixes all 61 pyright errors and ensures type safety matches the main branch standards.
1 parent 17b321c commit 95304e4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/shared/test_streamable_http.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ async def initialized_client_session(basic_server: None, basic_server_url: str):
852852

853853

854854
@pytest.mark.anyio
855-
async def test_streamable_http_client_basic_connection(basic_server, basic_server_url):
855+
async def test_streamable_http_client_basic_connection(basic_server: None, basic_server_url: str):
856856
"""Test basic client connection with initialization."""
857857
async with streamable_http_client(f"{basic_server_url}/mcp") as (
858858
read_stream,
@@ -870,7 +870,7 @@ async def test_streamable_http_client_basic_connection(basic_server, basic_serve
870870

871871

872872
@pytest.mark.anyio
873-
async def test_streamable_http_client_resource_read(initialized_client_session):
873+
async def test_streamable_http_client_resource_read(initialized_client_session: ClientSession):
874874
"""Test client resource read functionality."""
875875
response = await initialized_client_session.read_resource(uri=AnyUrl("foobar://test-resource"))
876876
assert len(response.contents) == 1
@@ -880,7 +880,7 @@ async def test_streamable_http_client_resource_read(initialized_client_session):
880880

881881

882882
@pytest.mark.anyio
883-
async def test_streamable_http_client_tool_invocation(initialized_client_session):
883+
async def test_streamable_http_client_tool_invocation(initialized_client_session: ClientSession):
884884
"""Test client tool invocation."""
885885
# First list tools
886886
tools = await initialized_client_session.list_tools()
@@ -895,7 +895,7 @@ async def test_streamable_http_client_tool_invocation(initialized_client_session
895895

896896

897897
@pytest.mark.anyio
898-
async def test_streamable_http_client_error_handling(initialized_client_session):
898+
async def test_streamable_http_client_error_handling(initialized_client_session: ClientSession):
899899
"""Test error handling in client."""
900900
with pytest.raises(McpError) as exc_info:
901901
await initialized_client_session.read_resource(uri=AnyUrl("unknown://test-error"))
@@ -904,7 +904,7 @@ async def test_streamable_http_client_error_handling(initialized_client_session)
904904

905905

906906
@pytest.mark.anyio
907-
async def test_streamable_http_client_session_persistence(basic_server, basic_server_url):
907+
async def test_streamable_http_client_session_persistence(basic_server: None, basic_server_url: str):
908908
"""Test that session ID persists across requests."""
909909
async with streamable_http_client(f"{basic_server_url}/mcp") as (
910910
read_stream,
@@ -932,7 +932,7 @@ async def test_streamable_http_client_session_persistence(basic_server, basic_se
932932

933933

934934
@pytest.mark.anyio
935-
async def test_streamable_http_client_json_response(json_response_server, json_server_url):
935+
async def test_streamable_http_client_json_response(json_response_server: None, json_server_url: str):
936936
"""Test client with JSON response mode."""
937937
async with streamable_http_client(f"{json_server_url}/mcp") as (
938938
read_stream,
@@ -960,7 +960,7 @@ async def test_streamable_http_client_json_response(json_response_server, json_s
960960

961961

962962
@pytest.mark.anyio
963-
async def test_streamable_http_client_get_stream(basic_server, basic_server_url):
963+
async def test_streamable_http_client_get_stream(basic_server: None, basic_server_url: str):
964964
"""Test GET stream functionality for server-initiated messages."""
965965
import mcp.types as types
966966
from mcp.shared.session import RequestResponder
@@ -1001,7 +1001,7 @@ async def message_handler( # pragma: no branch
10011001

10021002

10031003
@pytest.mark.anyio
1004-
async def test_streamable_http_client_session_termination(basic_server, basic_server_url):
1004+
async def test_streamable_http_client_session_termination(basic_server: None, basic_server_url: str):
10051005
"""Test client session termination functionality."""
10061006

10071007
captured_session_id = None
@@ -1043,7 +1043,9 @@ async def test_streamable_http_client_session_termination(basic_server, basic_se
10431043

10441044

10451045
@pytest.mark.anyio
1046-
async def test_streamable_http_client_session_termination_204(basic_server, basic_server_url, monkeypatch):
1046+
async def test_streamable_http_client_session_termination_204(
1047+
basic_server: None, basic_server_url: str, monkeypatch: pytest.MonkeyPatch
1048+
):
10471049
"""Test client session termination functionality with a 204 response.
10481050
10491051
This test patches the httpx client to return a 204 response for DELETEs.
@@ -1108,7 +1110,7 @@ async def mock_delete(self: httpx.AsyncClient, *args: Any, **kwargs: Any) -> htt
11081110

11091111

11101112
@pytest.mark.anyio
1111-
async def test_streamable_http_client_resumption(event_server):
1113+
async def test_streamable_http_client_resumption(event_server: tuple[SimpleEventStore, str]):
11121114
"""Test client session resumption using sync primitives for reliable coordination."""
11131115
_, server_url = event_server
11141116

0 commit comments

Comments
 (0)