-
-
Notifications
You must be signed in to change notification settings - Fork 32
Migrate from mypy to ty for type checking #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace mypy with ty (Astral's new type checker) - Update all configuration files (pyproject.toml, setup.cfg) - Update GitHub Actions workflow to use uvx ty check - Update AGENT.md, Makefile, and dev.py with new command - Remove mypy and types-setuptools from requirements-dev.in - Fix type errors detected by ty (remove unused imports, add type ignore comments for intentional monkey patching) - All 153 tests pass - Ty type checking passes with no errors Amp-Thread-ID: https://ampcode.com/threads/T-3de57a05-de3a-47f2-a4f0-bc95e78d8d13 Co-authored-by: Amp <amp@ampcode.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR migrates the project from mypy to Astral's ty type checker by replacing dependencies and commands, updating configuration and CI workflows, and addressing ty-reported type errors with suppression comments. Flow diagram for developer type checking commands after migrationflowchart TD
Developer["Developer"] -->|"make typecheck"| Ty_Check["uvx ty check json2xml tests"]
Developer -->|"python dev.py typecheck"| Ty_Check
Developer -->|"uvx ty check json2xml tests"| Ty_Check
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #252 +/- ##
=======================================
Coverage 99.30% 99.30%
=======================================
Files 3 3
Lines 288 288
=======================================
Hits 286 286
Misses 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Remove the empty [tool.ty] section from setup.cfg now that all ty configuration lives in pyproject.toml to avoid confusion.
- Populate the [tool.ty] section in pyproject.toml with the equivalent strictness flags from mypy (e.g., disallow_untyped_defs, no_implicit_optional) to preserve previous type safety guarantees.
- Instead of sprinkling type: ignore on test assignments, consider updating the function or module type signatures so mocks satisfy the types and avoid masking potential issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the empty [tool.ty] section from setup.cfg now that all ty configuration lives in pyproject.toml to avoid confusion.
- Populate the [tool.ty] section in pyproject.toml with the equivalent strictness flags from mypy (e.g., disallow_untyped_defs, no_implicit_optional) to preserve previous type safety guarantees.
- Instead of sprinkling type: ignore on test assignments, consider updating the function or module type signatures so mocks satisfy the types and avoid masking potential issues.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Ty needs to find installed packages in a virtual environment. Create a venv and activate it before running ty check.
Update the lint workflow to use ty instead of mypy for type checking. Verified locally: - ✅ ruff check passed - ✅ ty check passed - ✅ all 153 tests passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New security issues found
This PR migrates the project from mypy to ty, Astral's new type checker.
Changes
uvx ty check
)pyproject.toml
with[tool.ty]
configurationuvx ty check
Why ty?
Testing
Documentation
https://docs.astral.sh/ty/
Summary by Sourcery
Migrate static type checking from mypy to Astral's ty and update all related configurations, scripts, CI workflows, documentation, and tests accordingly.
Enhancements:
Build:
CI:
Documentation:
Tests:
Chores: