Replace mypy with ty for static type checking#585
Conversation
ty (from Astral, makers of ruff/uv) replaces mypy as the project's static type checker. Benchmark on this codebase (631 source files): | Metric | mypy | ty | Speedup | |-------------|----------|-------|---------| | Cold cache | 184.6s | 0.79s | ~234x | | Warm cache | 13.9s | 0.83s | ~17x | Changes: - Add ty to lint deps, remove mypy + mypy-extensions (keep mypy-protobuf for protoc stub generation) - Migrate mypy.ini config to [tool.ty.*] sections in pyproject.toml - Update Makefile type_check target: `uv run ty check` - Downgrade 12 rule categories to "warn" for initial migration; a follow-up PR will fix the 226 warnings and promote them back to errors - Update docs (CLAUDE.md, README.md, CHANGELOG.md, .claude/formatting.md) - Update .gitignore/.dockerignore cache directory references - Replace "mypy" mentions in source comments with generic "type checker" - Delete mypy.ini Co-Authored-By: shubhamvij <25601958+shubhamvij@users.noreply.github.com>
- Pin ty~=0.0.29 for reproducible builds - Add comment clarifying mypy-protobuf is for stub generation only - Exclude notebooks (*.ipynb) from type checking - Add comment about torch lacking inline types/stubs - Promote all ty rules back to default error severity (remove warn downgrades — fixes come in a follow-up PR) - Add [[tool.ty.overrides]] to suppress errors in generated *_pb2.py files that cannot be fixed Co-Authored-By: shubhamvij <25601958+shubhamvij@users.noreply.github.com>
svij-sc
left a comment
There was a problem hiding this comment.
I updated the downstream PR where I addressed the ty fixes and to it added some new fixes identified by @kmontemayor2-sc below.
Ref: #586
kmontemayor2-sc
left a comment
There was a problem hiding this comment.
I do feel pretty strongly about not type ignoring torch, WDYT about including #597 as part of the follow up here?
Otherwise this LGTM, thanks for the work :)
Co-authored-by: shubhamvij <25601958+shubhamvij@users.noreply.github.com> Co-authored-by: Kyle Montemayor <kmontemayor2@snapchat.com> Co-authored-by: kmontemayor <kyle.e.montemayor@gmail.com>
I pulled in the changes - thanks @kmontemayor2-sc |
kmontemayor2-sc
left a comment
There was a problem hiding this comment.
Awesome work Shubham! Really appreciate it :)
mkolodner-sc
left a comment
There was a problem hiding this comment.
Stamped with a comment/question, thanks!
ty (from Astral, makers of ruff/uv) replaces mypy as the project's static type checker.
The ty fixes are introduced here: #586
Benchmarked on the code base (631 source files):
Changes:
uv run ty checkScope of work done
Where is the documentation for this feature?: N/A
Did you add automated tests or write a test plan?
Updated Changelog.md? NO
Ready for code review?: YES