Add pyright strict mode on the whole project (#1254)
This commit is contained in:
parent
ef4e167c1a
commit
c7671e470c
1 changed files with 652 additions and 674 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from collections.abc import AsyncGenerator
|
||||
from typing import Any
|
||||
|
||||
import anyio
|
||||
import pytest
|
||||
|
|
@ -7,16 +8,14 @@ import mcp.types as types
|
|||
from mcp.client.session import ClientSession
|
||||
from mcp.server.lowlevel.server import Server
|
||||
from mcp.shared.exceptions import McpError
|
||||
from mcp.shared.memory import (
|
||||
create_client_server_memory_streams,
|
||||
create_connected_server_and_client_session,
|
||||
)
|
||||
from mcp.shared.memory import create_client_server_memory_streams, create_connected_server_and_client_session
|
||||
from mcp.types import (
|
||||
CancelledNotification,
|
||||
CancelledNotificationParams,
|
||||
ClientNotification,
|
||||
ClientRequest,
|
||||
EmptyResult,
|
||||
TextContent,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ async def test_request_cancellation():
|
|||
|
||||
# Register the tool handler
|
||||
@server.call_tool()
|
||||
async def handle_call_tool(name: str, arguments: dict | None) -> list:
|
||||
async def handle_call_tool(name: str, arguments: dict[str, Any] | None) -> list[TextContent]:
|
||||
nonlocal request_id, ev_tool_called
|
||||
if name == "slow_tool":
|
||||
request_id = server.request_context.request_id
|
||||
|
|
@ -83,7 +82,7 @@ async def test_request_cancellation():
|
|||
|
||||
return server
|
||||
|
||||
async def make_request(client_session):
|
||||
async def make_request(client_session: ClientSession):
|
||||
nonlocal ev_cancelled
|
||||
try:
|
||||
await client_session.send_request(
|
||||
|
|
@ -134,14 +133,11 @@ async def test_connection_closed():
|
|||
ev_closed = anyio.Event()
|
||||
ev_response = anyio.Event()
|
||||
|
||||
async with create_client_server_memory_streams() as (
|
||||
client_streams,
|
||||
server_streams,
|
||||
):
|
||||
async with create_client_server_memory_streams() as (client_streams, server_streams):
|
||||
client_read, client_write = client_streams
|
||||
server_read, server_write = server_streams
|
||||
|
||||
async def make_request(client_session):
|
||||
async def make_request(client_session: ClientSession):
|
||||
"""Send a request in a separate task"""
|
||||
nonlocal ev_response
|
||||
try:
|
||||
|
|
@ -165,10 +161,7 @@ async def test_connection_closed():
|
|||
|
||||
async with (
|
||||
anyio.create_task_group() as tg,
|
||||
ClientSession(
|
||||
read_stream=client_read,
|
||||
write_stream=client_write,
|
||||
) as client_session,
|
||||
ClientSession(read_stream=client_read, write_stream=client_write) as client_session,
|
||||
):
|
||||
tg.start_soon(make_request, client_session)
|
||||
tg.start_soon(mock_server)
|
||||
|
|
|
|||
Loading…
Reference in a new issue