Mypy ty migration#682
Open
abelaba wants to merge 5 commits intooptimagic-dev:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the type-checking from mypy to ty. Type checking is applied to the
src,.toolsandtestsfolders.Changes
Default configuration
ANN001that checks that function arguments have type annotations andANN201that checks that public functions and methods have return type annotations. Previously handled bydisallow_incomplete_defsanddisallow_untyped_defsin mypy.check_untyped_defs,no_implicit_optionalcorresponding ty rule,warn_redundant_castscorresponding ty rule andwarn_unused_ignorescorresponding ty rule are default behaviors in ty.Mypy Overrides
ruffsection.Test overrides
# ty: ignore[code]for the current errors in the tests folder.Ignoring missing imports
allowed-unresolved-importsfor modules that don't exist in the environment, andreplace-imports-with-anyfor modules that exist in the environment but don't have type definitions.Additional changes
type: ignorestatements and addedty: ignorestatements.mypydependency, added a pixi task fortyand replaced the ci workflow for type checking to use this pixi task.sql-alchemy-stubsbecausesqlalchemy>=2.0includes typing by default See: https://docs.sqlalchemy.org/en/21/changelog/whatsnew_20.html#new-typing-support-in-core-and-orm-stubs-extensions-no-longer-usedNext Steps
ty: ignorestatements currently added.Note
The only rule that can't currently be handled is
disallow_any_genericsby mypy. This rule doesnt have a corresponding rule in ruff or ty. Current open issue in ruff: astral-sh/ruff#5871Closes: #677