Skip to content

Commit 4cabf84

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 b2ef979 commit 4cabf84

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

833833

834834
@pytest.mark.anyio
835-
async def test_streamable_http_client_basic_connection(basic_server, basic_server_url):
835+
async def test_streamable_http_client_basic_connection(basic_server: None, basic_server_url: str):
836836
"""Test basic client connection with initialization."""
837837
async with streamable_http_client(f"{basic_server_url}/mcp") as (
838838
read_stream,
@@ -850,7 +850,7 @@ async def test_streamable_http_client_basic_connection(basic_server, basic_serve
850850

851851

852852
@pytest.mark.anyio
853-
async def test_streamable_http_client_resource_read(initialized_client_session):
853+
async def test_streamable_http_client_resource_read(initialized_client_session: ClientSession):
854854
"""Test client resource read functionality."""
855855
response = await initialized_client_session.read_resource(uri=AnyUrl("foobar://test-resource"))
856856
assert len(response.contents) == 1
@@ -860,7 +860,7 @@ async def test_streamable_http_client_resource_read(initialized_client_session):
860860

861861

862862
@pytest.mark.anyio
863-
async def test_streamable_http_client_tool_invocation(initialized_client_session):
863+
async def test_streamable_http_client_tool_invocation(initialized_client_session: ClientSession):
864864
"""Test client tool invocation."""
865865
# First list tools
866866
tools = await initialized_client_session.list_tools()
@@ -875,7 +875,7 @@ async def test_streamable_http_client_tool_invocation(initialized_client_session
875875

876876

877877
@pytest.mark.anyio
878-
async def test_streamable_http_client_error_handling(initialized_client_session):
878+
async def test_streamable_http_client_error_handling(initialized_client_session: ClientSession):
879879
"""Test error handling in client."""
880880
with pytest.raises(McpError) as exc_info:
881881
await initialized_client_session.read_resource(uri=AnyUrl("unknown://test-error"))
@@ -884,7 +884,7 @@ async def test_streamable_http_client_error_handling(initialized_client_session)
884884

885885

886886
@pytest.mark.anyio
887-
async def test_streamable_http_client_session_persistence(basic_server, basic_server_url):
887+
async def test_streamable_http_client_session_persistence(basic_server: None, basic_server_url: str):
888888
"""Test that session ID persists across requests."""
889889
async with streamable_http_client(f"{basic_server_url}/mcp") as (
890890
read_stream,
@@ -912,7 +912,7 @@ async def test_streamable_http_client_session_persistence(basic_server, basic_se
912912

913913

914914
@pytest.mark.anyio
915-
async def test_streamable_http_client_json_response(json_response_server, json_server_url):
915+
async def test_streamable_http_client_json_response(json_response_server: None, json_server_url: str):
916916
"""Test client with JSON response mode."""
917917
async with streamable_http_client(f"{json_server_url}/mcp") as (
918918
read_stream,
@@ -940,7 +940,7 @@ async def test_streamable_http_client_json_response(json_response_server, json_s
940940

941941

942942
@pytest.mark.anyio
943-
async def test_streamable_http_client_get_stream(basic_server, basic_server_url):
943+
async def test_streamable_http_client_get_stream(basic_server: None, basic_server_url: str):
944944
"""Test GET stream functionality for server-initiated messages."""
945945
import mcp.types as types
946946
from mcp.shared.session import RequestResponder
@@ -981,7 +981,7 @@ async def message_handler(
981981

982982

983983
@pytest.mark.anyio
984-
async def test_streamable_http_client_session_termination(basic_server, basic_server_url):
984+
async def test_streamable_http_client_session_termination(basic_server: None, basic_server_url: str):
985985
"""Test client session termination functionality."""
986986

987987
captured_session_id = None
@@ -1023,7 +1023,9 @@ async def test_streamable_http_client_session_termination(basic_server, basic_se
10231023

10241024

10251025
@pytest.mark.anyio
1026-
async def test_streamable_http_client_session_termination_204(basic_server, basic_server_url, monkeypatch):
1026+
async def test_streamable_http_client_session_termination_204(
1027+
basic_server: None, basic_server_url: str, monkeypatch: pytest.MonkeyPatch
1028+
):
10271029
"""Test client session termination functionality with a 204 response.
10281030
10291031
This test patches the httpx client to return a 204 response for DELETEs.
@@ -1088,7 +1090,7 @@ async def mock_delete(self: httpx.AsyncClient, *args: Any, **kwargs: Any) -> htt
10881090

10891091

10901092
@pytest.mark.anyio
1091-
async def test_streamable_http_client_resumption(event_server):
1093+
async def test_streamable_http_client_resumption(event_server: tuple[SimpleEventStore, str]):
10921094
"""Test client session resumption using sync primitives for reliable coordination."""
10931095
_, server_url = event_server
10941096

0 commit comments

Comments
 (0)