Repository navigation
Implicit re-exports should not be disabled for installed PEP 561 packages #8754
Description
Activity
This seems to be caused by
--no-implicit-reexport. Implicit re-exports should always be allowed in PEP 561 packages, but that's not the case right now.As a workaround, you can run mypy with
--strict --implicit-reexport.Reacted by Gordon P. Hemsley, Jaanus Varus, Stefan Hagen and David Gilman- changed the title
[-]mypy reports missing module attribute that it knows is there[/-][+]Implicit re-exports should not be disabled for installed PEP 561 packages[/+]on May 1, 2020 - addedbugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct code
on May 1, 2020 - added 2 commits that reference this issue
on Jun 1, 2020 Note that #9237 should improve the error message here
- added 2 commits that reference this issue
on Jun 24, 2021 Implicit re-exports should always be allowed in PEP 561 packages, but that's not the case right now.
How come @JukkaL? I think implicit re-export should be an opt-in, not always-on feature. I could imagine py.typed file containing some flag to enable/disable this.
Implicit re-exports should always be allowed in PEP 561 packages, but that's not the case right now.
This contradicts what (I thought) we had agreed to in the typing-sig discussion on this topic. If a package claims to be py.typed, then it needs to follow typing rules and be explicit about what symbols are exported from each submodule. Pyright assumes that py.typed packages never use implicit re-exports. Here is the guidance we have been providing to package authors, and pyright's implementation is consistent with this guidance. I would encourage mypy to default to the same behavior to provide consistency for package authors.
Reacted by Takahiro Ueda, Thibault Derousseaux and ippeiReacted by Bernát Gábor- added a commit that references this issue
on Sep 4, 2023 - added a commit that references this issue
on Sep 4, 2023
With:
the following code:
produces the following output:
Note that each error message suggests an alternative that the other error message insists does not exist.
Tenacity only just added the bare minimum of type hints (jd/tenacity#221), so I don't know if there's some conflict there, but even if that's the case, this seems like a bug in mypy.
Possibly related mypy issues: #8220, #8210, #7125, #7029, #6551, #4930