Skip to content

~143 mypy-style # type: ignore[code] comments do nothing under ty; global ty rule disables are broader than documented #507

Closed

Description

@antosubash

Tier 3: type-checking hygiene

Problem

  • The repo type-checks with ty. Nothing runs mypy (no references in the Makefile, pyproject or workflows).
  • There are still about 143 # type: ignore[<mypy code>] comments: arg-type 60, attr-defined 35, call-arg 19, override 6, method-assign 6, and others.
  • Tested with ty 0.0.89: a bare # type: ignore suppresses the whole line, but a bracketed one is matched against ty's rule names. So # type: ignore[attr-defined] did not suppress an invalid-return-type. ty also doesn't report these comments as unused, so they pile up as noise that misleads readers about what is being hidden.
  • pyproject.toml:105-118 disables six rules globally. CLAUDE.md lists five; it also disables invalid-assignment.
  • The global invalid-argument-type disable hides real bugs. Example: _tenant.py:63 passes an unvalidated object as tenant_id into TenantResolution, so a resolver returning a UUID or an int flows into string comparisons. The ignore comment on that line isn't what silences it; the global disable is.

Fix

  1. Delete the mypy-coded ignores. Rewrite the few that are needed as # ty: ignore[<rule>], which ty does report when unused.
  2. Narrow invalid-argument-type and invalid-assignment to per-path overrides, or to warn, instead of global ignore, and fix what turns up in non-ORM code.
  3. Validate or coerce tenant_id to str at the resolver boundary in _tenant.py.
  4. Update the CLAUDE.md list of disabled rules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions