Promote 7 ty rules from ignore to warn, fix 9 violations (#3852)

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) <noreply@anthropic.com>
This commit is contained in:
Bill Easton 2026-04-12 11:50:56 -05:00 committed by GitHub
commit 7825355b98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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}")

View file

@ -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)

View file

@ -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

View file

@ -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)