Closed
Description
Mypy currently handles module re-exports in stub files the same way it handles them with regular Python files. That is, any symbol imported at the global level is available for re-export. However, PEP 484 contains the following lines in the section on stub files:
- Modules and variables imported into the stub are not considered exported from the stub unless the import uses the
import ... as ...
form or the equivalentfrom ... import ... as ...
form.- However, as an exception to the previous bullet, all objects imported into a stub using
from ... import *
are considered exported. (This makes it easier to re-export all objects from a given module that may vary by Python version.)
I suspect this may be a bit tricky to implement cleanly because iirc, mypy currently doesn't have a mechanism that lets symbols be defined inside a module while being hidden outside (in part because Python itself doesn't really have such a mechanism). Also, my "this might do weird things with incremental mode" senses are tingling.
For context, this issue came up in this pull request: python/typeshed#1471
Metadata
Metadata
Assignees
Labels
No labels