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

Do not duplicate nox.Session interface in type stubs #391

Merged
merged 2 commits into from
Jun 11, 2021

Conversation

cjolowicz
Copy link
Owner

@cjolowicz cjolowicz commented Jun 11, 2021

This PR changes the type stubs distributed with nox-poetry to pretend that nox_poetry.Session derives from nox.Session.

Rationale:

Currently, the type stubs for the sessions module duplicate the nox.Session interface. This is done because nox_poetry.Session delegates to nox.Session via __getattr__. Unfortunately, this has some chance of breaking type checkers with every Nox release. For example, a Noxfile passing posargs to session.notify (introduced in Nox 2021.6.6) will not pass type checks, if session is an instance of nox_poetry.Session.

Duplicating the nox.Session interface in our type stubs is extremely brittle and
likely to break with every Nox interface. Instead, pretend that our Session
derives from nox.Session.
@cjolowicz cjolowicz added the refactoring Refactoring label Jun 11, 2021
@cjolowicz cjolowicz merged commit 809db93 into main Jun 11, 2021
@cjolowicz cjolowicz deleted the fix-brittle-types branch June 11, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant