Include server examples folder in pyright check (#667)

This commit is contained in:
ihrpr
2025-05-15 09:29:36 +01:00
committed by GitHub
parent 0a388b642f
commit b3fbee9c48
8 changed files with 15 additions and 10 deletions

View File

@@ -4,4 +4,4 @@ import sys
from mcp_simple_auth.server import main
sys.exit(main())
sys.exit(main()) # type: ignore[call-arg]

View File

@@ -2,4 +2,4 @@ import sys
from .server import main
sys.exit(main())
sys.exit(main()) # type: ignore[call-arg]

View File

@@ -2,4 +2,4 @@ import sys
from .server import main
sys.exit(main())
sys.exit(main()) # type: ignore[call-arg]

View File

@@ -2,7 +2,7 @@ import anyio
import click
import mcp.types as types
from mcp.server.lowlevel import Server
from pydantic import FileUrl
from pydantic import AnyUrl
SAMPLE_RESOURCES = {
"greeting": "Hello! This is a sample text resource.",
@@ -26,7 +26,7 @@ def main(port: int, transport: str) -> int:
async def list_resources() -> list[types.Resource]:
return [
types.Resource(
uri=FileUrl(f"file:///{name}.txt"),
uri=AnyUrl(f"file:///{name}.txt"),
name=name,
description=f"A sample text resource named {name}",
mimeType="text/plain",
@@ -35,7 +35,9 @@ def main(port: int, transport: str) -> int:
]
@app.read_resource()
async def read_resource(uri: FileUrl) -> str | bytes:
async def read_resource(uri: AnyUrl) -> str | bytes:
if uri.path is None:
raise ValueError(f"Invalid resource path: {uri}")
name = uri.path.replace(".txt", "").lstrip("/")
if name not in SAMPLE_RESOURCES:

View File

@@ -1,4 +1,7 @@
from .server import main
if __name__ == "__main__":
main()
# Click will handle CLI arguments
import sys
sys.exit(main()) # type: ignore[call-arg]

View File

@@ -1,4 +1,4 @@
from .server import main
if __name__ == "__main__":
main()
main() # type: ignore[call-arg]

View File

@@ -2,4 +2,4 @@ import sys
from .server import main
sys.exit(main())
sys.exit(main()) # type: ignore[call-arg]

View File

@@ -85,7 +85,7 @@ Issues = "https://github.com/modelcontextprotocol/python-sdk/issues"
packages = ["src/mcp"]
[tool.pyright]
include = ["src/mcp", "tests"]
include = ["src/mcp", "tests", "examples/servers"]
venvPath = "."
venv = ".venv"
strict = ["src/mcp/**/*.py"]