Add pyright strict mode on the whole project (#1254)

This commit is contained in:
Marcelo Trylesinski 2025-08-11 19:56:37 +02:00 • committed by GitHub
commit c7671e470c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,7 +25,7 @@ dependencies = [
"anyio>=4.5",
"httpx>=0.27",
"httpx-sse>=0.4",
"pydantic>=2.8.0,<3.0.0",
"pydantic>=2.11.0,<3.0.0",
"starlette>=0.27",
"python-multipart>=0.0.9",
"sse-starlette>=1.6.1",
@ -88,10 +88,19 @@ Issues = "https://github.com/modelcontextprotocol/python-sdk/issues"
packages = ["src/mcp"]
[tool.pyright]
typeCheckingMode = "strict"
include = ["src/mcp", "tests", "examples/servers", "examples/snippets"]
venvPath = "."
venv = ".venv"
strict = ["src/mcp/**/*.py"]
# The FastAPI style of using decorators in tests gives a `reportUnusedFunction` error.
# See https://github.com/microsoft/pyright/issues/7771 for more details.
# TODO(Marcelo): We should remove `reportPrivateUsage = false`. The idea is that we should test the workflow that uses
# those private functions instead of testing the private functions directly. It makes it easier to maintain the code source
# and refactor code that is not public.
executionEnvironments = [
{ root = "tests", reportUnusedFunction = false, reportPrivateUsage = false },
{ root = "examples/servers", reportUnusedFunction = false },
]
[tool.ruff.lint]
select = ["C4", "E", "F", "I", "PERF", "UP"]