Skip to content

chore: migrate type checking from mypy to pyright #4

@hey-granth

Description

@hey-granth

Summary

mypy is slow and has worse error messages compared to modern alternatives.
This issue tracks migrating type checking from mypy to pyright, which runs
as a daemon for near-instant incremental checks and is production-stable.

Motivation

  • mypy is significantly slower on incremental checks compared to pyright
  • Pyright error messages are more precise and actionable
  • Pyright is actively maintained by Microsoft and backs Pylance in VS Code
  • Daemon mode means subsequent checks in dev workflow are near-instant

Migration Steps

  • Add pyright as a dev dependency via uv add --dev pyright
  • Add pyrightconfig.json at the repo root
  • Run pyright in standard mode and fix all reported errors
  • Remove mypy from dev dependencies and pyproject.toml
  • Update CI workflow to replace mypy invocation with pyright
  • Update CONTRIBUTING.md or dev setup docs if mypy is mentioned

Initial Configuration

{
  "pythonVersion": "3.11",
  "typeCheckingMode": "standard",
  "venvPath": ".",
  "venv": ".venv"
}

Start with standard mode. Strict mode can be a follow-up once the
baseline is clean — strict on tree-sitter and rustworkx bindings may
produce noise from incomplete upstream stubs.

Notes

  • Pyright and mypy occasionally disagree on correctness. Pyright is generally correct when they diverge but some annotations may need adjustment during migration.
  • Do not migrate to ty (Astral) or Pyrefly (Meta) at this time. Both are pre-release and not production-stable. Revisit when either hits 1.0.

Out of Scope

  • Enabling strict mode (follow-up issue if desired)
  • Adding inline type annotations to currently untyped functions

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions