Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Python, if module A defines a name
name
, and module B doesimport name from A
, then another module C canimport name from B
.Sometimes it is intentional -- module B is meant to "reexport"
name
.But sometimes it is just confusion/inconsistency on where
name
should be imported from.mypy has a flag
--no-implicit-reexport
which puts some order into this. A name can only be imported from a module if__all__
includes the namefrom ... import .. as name
.This flag is included in mypy's
--strict
flag.I like this flag, but I realize it is a bit controversial, and in particular item 3 above is a bit unfriendly to contributors who don't
know about it. So I didn't intend to add it to pytest.
But while investigating issue #7589 I came upon mypy issue python/mypy#8754 which causes
--no-implicit-reexport
to leak into installed libraries and causes some unexpected typing differences in pytest if the user uses this flag.Since the diff mostly makes sense, let's just conform to it.