-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
PEP-484 contains the following paragraph, which is specific to .pyi stubs:
Modules and variables imported into the stub are not considered exported from the stub unless the import uses the
import ... as ... formor the equivalentfrom ... import ... as ... form
PEP-561 introduced the option to use regular .py files as external type declarations, by simply adding py.typed to a package. This however causes confusion about whether top-level __init__.py files should adhere to the paragraph above in order to have their symbols exported or not.
My personal interpretation is no, as it makes things extremely unreadable and a full python module is not a stub; also this is contrary to the best practice adopted by virtually all libraries I've observed. However, pyright interpreted it in the opposite way and will ignore symbols not imported in the above way. An authoritative clarification in PEP-561 would be appreciated.