Skip to content
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 for running mypy #2431

Merged
merged 12 commits into from
Dec 29, 2023
1 change: 1 addition & 0 deletions changelog/2431.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a tox environment for running mypy.
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
python_version = 3.9
pretty = true
exclude = (?x)(
docs
docs|
.tox
)

enable_error_code = ignore-without-code
Expand Down
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,13 @@ docs = [
"tox >= 4.4.0",
"unidecode >= 1.3.6",
]
# Some of these packages contain typing information for packages that
# don't themselves contain type hints. We might want to move these from
# the tests section and into the specific mypy environment.
tests = [
"hypothesis >= 6.35.1",
"pandas-stubs >= 1.5.0.221010", # used by mypy
"pre-commit >= 3.0.0",
"pytest-regressions >= 2.3.1",
"pytest-xdist >= 3.0.2",
"tomli >= 2.0.1",
"tox >= 4.3.1",
"types-requests >= 2.27.1", # used by mypy
"types-tqdm >= 4.66.0.3", # used by mypy
Comment on lines -85 to -97
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that the type stub packages can be installed using the --install-types flag for mypy, so they're not needed here. Using that flag has the advantage that it'll probably get updated with type stub packages as more are created or obsoleted, which means less work for us to do!

]
[project.urls]
Changelog = "https://docs.plasmapy.org/en/stable/whatsnew/index.html"
Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,9 @@ basepython = python3.9
extras =
deps =
commands = python -c 'import plasmapy'

[testenv:mypy]
deps =
mypy >= 1.8.0
commands =
mypy plasmapy --install-types --non-interactive --show-error-context --show-error-code-links --pretty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably want to play with these flags to get the error reporting settings that work best for us.