Skip to content

Commit c800467

Browse files
committed
fix: resolve pyright type errors in test file
- Add type annotation for handler_invocations list - Import CallToolResult for proper type narrowing - Add explicit isinstance check for asyncio.gather results - Fixes type errors that were preventing CI from passing
1 parent ef3c201 commit c800467

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/server/test_tool_cache_refresh_bug.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from mcp.client.session import ClientSession
1313
from mcp.server.lowlevel import Server
14-
from mcp.types import ListToolsRequest, TextContent, Tool
14+
from mcp.types import CallToolResult, ListToolsRequest, TextContent, Tool
1515

1616

1717
@pytest.mark.anyio
@@ -28,7 +28,7 @@ async def test_no_nested_handler_invocation_on_cache_refresh():
2828
server = Server("test-server")
2929

3030
# Track handler invocations
31-
handler_invocations = []
31+
handler_invocations: list[str] = []
3232

3333
@server.list_tools()
3434
async def list_tools():
@@ -178,6 +178,8 @@ async def run_server():
178178
# Verify all calls succeeded
179179
for i, result in enumerate(results):
180180
assert not isinstance(result, Exception), f"Tool {i} failed: {result}"
181+
# Type narrowing: result is CallToolResult at this point, not Exception
182+
assert isinstance(result, CallToolResult)
181183
assert not result.isError
182184
content = result.content[0]
183185
assert isinstance(content, TextContent)

0 commit comments

Comments
 (0)