-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add a tox environment to run mypy for static type checking #15815
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
👋 Thank you for your draft pull request! Do you know that you can use |
Does this supersede #15794 ? |
Thank you for the question! It's more like this PR depends on #15794 rather than superseding it. These PRs are two of the three steps that we took for adding mypy to PlasmaPy's CI suite:
I wanted to separate the PRs in case there's a decision to take a different approach than #15794. |
deps = | ||
mypy | ||
commands = | ||
mypy {tox_root}/astropy --install-types --non-interactive |
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.
There are some packages that aren't typed themselves, but have created type stub packages that contain type information. The --install-types
flag "causes mypy to install known missing stub packages for third-party libraries using pip", which means that mypy would have access to verified type information for packages like pandas, PyYAML, beautifulsoup4, etc. We could also manually add other type stub packages here, or otherwise specify mypy not to follow certain imports.
A follow-up to this exploratory PR: I mentioned in this post that it's worth considering alternatives to mypy such as pyright. |
@namurphy, I'm in favor of this! |
Blocked by:
This exploratory pull request would add a tox environment for running mypy for static type checking of type hint annotations. It could be run using:
This PR is based off of PlasmaPy/PlasmaPy#2431. A similar PR to add mypy to PlasmaPy's CI suite is PlasmaPy/PlasmaPy#2432. I'm not adding mypy to the CI suite in this PR because that would be a much bigger step than adding a tox environment.
This PR would need to go along with a PR to add a
mypy.ini
file (e.g., #12971 or #15769) that ignores all current errors, since running mypy without it leads to ∼1–2K errors (depending on the settings we choose).There has been a great discussion about typing in #15170.