Skip to content

Commit 4406b0e

Browse files
committed
fix: resolve pyright type checking errors in example file
- Use Callable from collections.abc instead of lowercase callable - Remove unnecessary isinstance check (dict[str, Any] is always dict) - Add explicit type annotations for variables to satisfy pyright
1 parent 7a924ef commit 4406b0e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/snippets/clients/llm_adapter_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import asyncio
1717
import os
18+
from collections.abc import Callable
1819
from typing import Any
1920

2021
from mcp import ClientSession, StdioServerParameters, types
@@ -381,16 +382,15 @@ def validate_tool(mcp_tool: types.Tool) -> None:
381382
raise SchemaConversionError("Tool inputSchema is required")
382383

383384
schema = mcp_tool.inputSchema
384-
if not isinstance(schema, dict):
385-
raise SchemaConversionError("inputSchema must be a dictionary")
385+
# inputSchema is already typed as dict[str, Any] in types.Tool, so no need to check
386386

387387
if schema.get("type") != "object":
388388
raise SchemaConversionError("inputSchema type must be 'object'")
389389

390390

391391
def convert_tools_batch(
392392
mcp_tools: list[types.Tool],
393-
converter_func: callable[[types.Tool], dict[str, Any]],
393+
converter_func: Callable[[types.Tool], dict[str, Any]],
394394
) -> tuple[list[dict[str, Any]], list[tuple[str, str]]]:
395395
"""Convert multiple MCP tools to provider format.
396396
@@ -401,13 +401,13 @@ def convert_tools_batch(
401401
Returns:
402402
Tuple of (converted tools, list of (tool_name, error_message) tuples).
403403
"""
404-
converted = []
405-
errors = []
404+
converted: list[dict[str, Any]] = []
405+
errors: list[tuple[str, str]] = []
406406

407407
for tool in mcp_tools:
408408
try:
409409
validate_tool(tool)
410-
converted_tool = converter_func(tool)
410+
converted_tool: dict[str, Any] = converter_func(tool)
411411
converted.append(converted_tool)
412412
except Exception as e:
413413
errors.append((tool.name, str(e)))

0 commit comments

Comments
 (0)