π The fast, Pythonic way to build MCP servers and clients.
Promote 7 ty rules from ignore to warn, fix 9 violations (#3852)
Bill Easton7825355b98d9
diff --git a/pyproject.toml b/pyproject.tomlindex fde57769b..3e44dfeeb 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -162,6 +162,15 @@ python-version = "3.10"# Some code uses `# ty: ignore[invalid-argument-type]` for this limitation.# TODO: Remove these ignores once ty supports union narrowing+# Promote rules from default-ignore to warn (becomes error via error-on-warning)+division-by-zero = "warn"+possibly-missing-attribute = "warn"+possibly-missing-import = "warn"+possibly-unresolved-reference = "warn"+unsupported-dynamic-base = "warn"+unsupported-operator = "warn"+unused-ignore-comment = "warn"+[tool.ty.terminal]error-on-warning = truediff --git a/src/fastmcp/mcp_config.py b/src/fastmcp/mcp_config.pyindex d4dbf2df5..8f9f836fc 100644--- a/src/fastmcp/mcp_config.py+++ b/src/fastmcp/mcp_config.py@@ -322,7 +322,7 @@ class MCPConfig(BaseModel):def from_file(cls, file_path: Path) -> Self:"""Load configuration from JSON file."""if file_path.exists() and (content := file_path.read_text().strip()):- return cls.model_validate_json(content)+ return cls.model_validate_json(content) # ty: ignore[possibly-unresolved-reference]raise ValueError(f"No MCP servers defined in the config: {file_path}")diff --git a/src/fastmcp/utilities/openapi/schemas.py b/src/fastmcp/utilities/openapi/schemas.pyindex 6eadffb5f..dd2df6010 100644--- a/src/fastmcp/utilities/openapi/schemas.py+++ b/src/fastmcp/utilities/openapi/schemas.py@@ -247,7 +247,8 @@ def _combine_schemas_and_map_params("header": set(),"cookie": set(),}- body_props = {}+ body_schema: dict[str, Any] = {}+ body_props: dict[str, Any] = {}for param in route.parameters:param_names_by_location[param.location].add(param.name)diff --git a/tests/server/test_input_validation.py b/tests/server/test_input_validation.pyindex f986f3769..b9008f7f9 100644--- a/tests/server/test_input_validation.py+++ b/tests/server/test_input_validation.py@@ -146,6 +146,7 @@ class TestPydanticModelArguments:)# This test verifies whether we handle stringified JSON+ error_msg = ""try:result = await client.call_tool("create_user", {"profile": stringified})# If this succeeds, we're handling stringified JSONdiff --git a/tests/utilities/json_schema_type/test_real_world_schemas.py b/tests/utilities/json_schema_type/test_real_world_schemas.pyindex 17d08f8e5..998a31d82 100644--- a/tests/utilities/json_schema_type/test_real_world_schemas.py+++ b/tests/utilities/json_schema_type/test_real_world_schemas.py@@ -206,6 +206,7 @@ def _test_provider(provider: str) -> ProviderResult:result.schemas += 1+ old_handler = signal.SIG_DFLif use_alarm:old_handler = signal.signal(signal.SIGALRM, _alarm_handler)signal.alarm(SCHEMA_TIMEOUT)