From 7825355b98d9ea562003e7b9c2bf95b947b02468 Mon Sep 17 00:00:00 2001 From: Bill Easton Date: Sun, 12 Apr 2026 11:50:56 -0500 Subject: [PATCH] Promote 7 ty rules from ignore to warn, fix 9 violations (#3852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enables stricter type checking by promoting rules that default to ignore: division-by-zero, possibly-missing-attribute, possibly-missing-import, possibly-unresolved-reference, unsupported-dynamic-base, unsupported-operator, unused-ignore-comment. 6 of the 7 rules had zero violations. possibly-unresolved-reference had 9 (5 in src/, 3 in tests/, 1 walrus-operator false positive suppressed with ty: ignore). 🤖 Generated with Claude Code Co-authored-by: Claude Opus 4.6 (1M context) --- pyproject.toml | 9 +++++++++ src/fastmcp/mcp_config.py | 2 +- src/fastmcp/utilities/openapi/schemas.py | 3 ++- tests/server/test_input_validation.py | 1 + .../json_schema_type/test_real_world_schemas.py | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 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 = true diff --git a/src/fastmcp/mcp_config.py b/src/fastmcp/mcp_config.py index 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.py index 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.py index 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 JSON diff --git a/tests/utilities/json_schema_type/test_real_world_schemas.py b/tests/utilities/json_schema_type/test_real_world_schemas.py index 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_DFL if use_alarm: old_handler = signal.signal(signal.SIGALRM, _alarm_handler) signal.alarm(SCHEMA_TIMEOUT)