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

Type-check noxfile.py #342

Merged
merged 3 commits into from Jun 11, 2020
Merged

Type-check noxfile.py #342

merged 3 commits into from Jun 11, 2020

Conversation

cjolowicz
Copy link
Owner

@cjolowicz cjolowicz commented May 26, 2020

Use the --python-executable option to mypy to point the type checker to the Python installation running Nox, rather than the virtual environment of the Nox session, when type-checking noxfile.py itself. This allows mypy to find the type information for Nox, without having to install Nox into the session. Nox distributes type information inline and declares this fact using the py.typed file specified in PEP 561.

Note that this check is somewhat indeterministic in local testing. The Nox version is only pinned in CI. For users with a pre-2020.5.24 version of Nox, the session will fail due to missing type hints. The session may also conceivably fail in the future if users install a newer version of Nox with breaking changes. (In the latter case, the failure serves as a useful reminder that noxfile.py needs to be adapted to the API changes.)

Closes #337

@cjolowicz cjolowicz added the enhancement New feature or request label May 26, 2020
@cjolowicz cjolowicz added this to the 2020.6.15 milestone May 26, 2020
@cjolowicz cjolowicz changed the title Typecheck noxfile Type-check noxfile.py May 26, 2020
@cjolowicz cjolowicz marked this pull request as draft June 10, 2020 14:04
@cjolowicz
Copy link
Owner Author

It would be better to point mypy to the Nox installation outside of the session. Needs investigation.

Use the --python-executable option to mypy to point the type checker to
the Python installation running Nox, rather than the virtual environment
of the Nox session, when type-checking noxfile.py itself. This allows
mypy to find the type information for Nox, without having to install Nox
into the session. Nox distributes type information inline and declares
this fact using the py.typed file specified in PEP 561.

Note that this check is somewhat indeterministic in local testing. The
Nox version is only pinned in CI. For users with a pre-2020.5.24 version
of Nox, the session will fail due to missing type hints. The session may
also conceivably fail in the future if users install a newer version of
Nox with breaking changes. (In the latter case, the failure serves as a
useful reminder that noxfile.py needs to be adapted to the API changes.)
@cjolowicz cjolowicz marked this pull request as ready for review June 11, 2020 05:53
@cjolowicz cjolowicz merged commit dbe17e2 into master Jun 11, 2020
@cjolowicz cjolowicz deleted the typecheck-noxfile branch June 11, 2020 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Nox types in mypy session
1 participant