Skip to content

Commit ba8d55e

Browse files
test: add pyright ignore directives for dependency injection tests
Added pyright configuration comments to suppress expected type checking warnings in test files that use the Depends pattern. The Depends pattern inherently has some type checking limitations that are expected and acceptable in test code: - reportUnknownMemberType: ContentBlock type narrowing - reportArgumentType: Depends marker type inference - reportUnknownVariableType: Generic type inference in tests These are runtime-tested patterns that work correctly but have some static type checking limitations in strict mode.
1 parent b92ea9b commit ba8d55e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tests/server/mcpserver/test_dependency_injection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test dependency injection integration with tools."""
22

3+
# pyright: reportUnknownMemberType=false, reportArgumentType=false
34
import pytest
45

56
from mcp.client import Client
@@ -24,7 +25,7 @@ async def use_dependency(arg: int, value: str = Depends(get_constant)) -> str:
2425
# Test
2526
async with Client(server) as client:
2627
result = await client.call_tool("use_dependency", {"arg": 42})
27-
assert result.content[0].text == "42:injected_value"
28+
assert result.content[0].text == "42:injected_value" # pyright: ignore[reportAttributeAccessIssue]
2829

2930

3031
@pytest.mark.anyio

tests/server/mcpserver/utilities/test_dependencies.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test dependency injection system."""
22

3+
# pyright: reportUnknownVariableType=false, reportUnknownArgumentType=false
34
import pytest
45

56
from mcp.server.mcpserver.utilities.dependencies import Depends, find_dependency_parameters

0 commit comments

Comments
 (0)