Skip to content

Commit 0f373e4

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 ac0e3df commit 0f373e4

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
@@ -987,7 +987,7 @@ async def initialized_client_session(basic_server: None, basic_server_url: str):
987987

988988

989989
@pytest.mark.anyio
990-
async def test_streamable_http_client_basic_connection(basic_server, basic_server_url):
990+
async def test_streamable_http_client_basic_connection(basic_server: None, basic_server_url: str):
991991
"""Test basic client connection with initialization."""
992992
async with streamable_http_client(f"{basic_server_url}/mcp") as (
993993
read_stream,
@@ -1005,7 +1005,7 @@ async def test_streamable_http_client_basic_connection(basic_server, basic_serve
10051005

10061006

10071007
@pytest.mark.anyio
1008-
async def test_streamable_http_client_resource_read(initialized_client_session):
1008+
async def test_streamable_http_client_resource_read(initialized_client_session: ClientSession):
10091009
"""Test client resource read functionality."""
10101010
response = await initialized_client_session.read_resource(uri=AnyUrl("foobar://test-resource"))
10111011
assert len(response.contents) == 1
@@ -1015,7 +1015,7 @@ async def test_streamable_http_client_resource_read(initialized_client_session):
10151015

10161016

10171017
@pytest.mark.anyio
1018-
async def test_streamable_http_client_tool_invocation(initialized_client_session):
1018+
async def test_streamable_http_client_tool_invocation(initialized_client_session: ClientSession):
10191019
"""Test client tool invocation."""
10201020
# First list tools
10211021
tools = await initialized_client_session.list_tools()
@@ -1030,7 +1030,7 @@ async def test_streamable_http_client_tool_invocation(initialized_client_session
10301030

10311031

10321032
@pytest.mark.anyio
1033-
async def test_streamable_http_client_error_handling(initialized_client_session):
1033+
async def test_streamable_http_client_error_handling(initialized_client_session: ClientSession):
10341034
"""Test error handling in client."""
10351035
with pytest.raises(McpError) as exc_info:
10361036
await initialized_client_session.read_resource(uri=AnyUrl("unknown://test-error"))
@@ -1039,7 +1039,7 @@ async def test_streamable_http_client_error_handling(initialized_client_session)
10391039

10401040

10411041
@pytest.mark.anyio
1042-
async def test_streamable_http_client_session_persistence(basic_server, basic_server_url):
1042+
async def test_streamable_http_client_session_persistence(basic_server: None, basic_server_url: str):
10431043
"""Test that session ID persists across requests."""
10441044
async with streamable_http_client(f"{basic_server_url}/mcp") as (
10451045
read_stream,
@@ -1067,7 +1067,7 @@ async def test_streamable_http_client_session_persistence(basic_server, basic_se
10671067

10681068

10691069
@pytest.mark.anyio
1070-
async def test_streamable_http_client_json_response(json_response_server, json_server_url):
1070+
async def test_streamable_http_client_json_response(json_response_server: None, json_server_url: str):
10711071
"""Test client with JSON response mode."""
10721072
async with streamable_http_client(f"{json_server_url}/mcp") as (
10731073
read_stream,
@@ -1095,7 +1095,7 @@ async def test_streamable_http_client_json_response(json_response_server, json_s
10951095

10961096

10971097
@pytest.mark.anyio
1098-
async def test_streamable_http_client_get_stream(basic_server, basic_server_url):
1098+
async def test_streamable_http_client_get_stream(basic_server: None, basic_server_url: str):
10991099
"""Test GET stream functionality for server-initiated messages."""
11001100
import mcp.types as types
11011101

@@ -1135,7 +1135,7 @@ async def message_handler( # pragma: no branch
11351135

11361136

11371137
@pytest.mark.anyio
1138-
async def test_streamable_http_client_session_termination(basic_server, basic_server_url):
1138+
async def test_streamable_http_client_session_termination(basic_server: None, basic_server_url: str):
11391139
"""Test client session termination functionality."""
11401140

11411141
captured_session_id = None
@@ -1177,7 +1177,9 @@ async def test_streamable_http_client_session_termination(basic_server, basic_se
11771177

11781178

11791179
@pytest.mark.anyio
1180-
async def test_streamable_http_client_session_termination_204(basic_server, basic_server_url, monkeypatch):
1180+
async def test_streamable_http_client_session_termination_204(
1181+
basic_server: None, basic_server_url: str, monkeypatch: pytest.MonkeyPatch
1182+
):
11811183
"""Test client session termination functionality with a 204 response.
11821184
11831185
This test patches the httpx client to return a 204 response for DELETEs.
@@ -1242,7 +1244,7 @@ async def mock_delete(self: httpx.AsyncClient, *args: Any, **kwargs: Any) -> htt
12421244

12431245

12441246
@pytest.mark.anyio
1245-
async def test_streamable_http_client_resumption(event_server):
1247+
async def test_streamable_http_client_resumption(event_server: tuple[SimpleEventStore, str]):
12461248
"""Test client session resumption using sync primitives for reliable coordination."""
12471249
_, server_url = event_server
12481250

0 commit comments

Comments
 (0)