-
Notifications
You must be signed in to change notification settings - Fork 927
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
Revisit our mypy
setup
#2156
Comments
Second to that, PyLance (which is better than PyRight) have built-in extension for these type hints which is better. Our mypy is very old (v0.961). Simply bumping it to 1.4.1 I get 267 errors. Not all of the errors are important but I think it helps a lot when we get these type correct for the functions that nested in many layers. It will also give us better insight to refactor.
|
Echoing a comment I made somewhere else about MyPy and pre-commit, see https://jaredkhan.com/blog/mypy-pre-commit An alternative is to use it as a pytest plugin rather than a linter https://github.com/realpython/pytest-mypy or just call it separately. |
And I agree upgrading to a recent version of MyPy is warranted. We can probably learn some things from kedro-org/kedro-viz#1419 |
Resolved in the following PRs: |
Description
Currently we are using
mypy
only in ourpre-commit
hook and we even don't have it as an explicittest_requirements.txt
dependency. If you are usingpyright
as a language server to explore Kedro's codebase, you will see a lot of type errors and warnings that you wouldn't catch through our pre-commit hook. Also Python's type annotations have evolved since we first started using it and we should catch up with these developments, e.g. the change of PEP 484 which disallows now inexplicit optional definitions:now has to become:
The goal of this is to end up as close as possible to be able to run
mypy --strict
on our codebase without any complains.Context
To improve the quality of our codebase and possibly uncover some bugs hidden bugs.
Possible Implementation
pre-commit
and runningmypy
locally produce the same outputmypy
version in dev requirements (test_requirements.txt
)mypy --strict
and fix as much errors as possiblemypy
to ignore the errors we cannot fix, e.g. the ones introduced to us by third-party packagesNote: don't run
mypy
onkedro.extras
because we're removing the datasets in 0.19.0Possible Alternatives
Another option is to move to
pyright
entirely and use it as a type checker instead ofmypy
, or maybe even use both?The text was updated successfully, but these errors were encountered: