forked from python/peps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEP 484: Clarify that submodules in a package are exported
See discussion in python/typeshed#1484 (comment). cc @ilevkivskyi @gvanrossum
- Loading branch information
1 parent
ea76e44
commit 51a178b
Showing
1 changed file
with
4 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1657,7 +1657,10 @@ Additional notes on stub files: | |
* 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.) | ||
given module that may vary by Python version.) Similarly, imports | ||
of submodules in the ``__init__.pyi`` files of a package are | ||
considered exported. For example, if ``a/__init__.pyi`` contains | ||
just ``from . import b``, then ``b`` is exported. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gvanrossum
|
||
|
||
* Stub files may be incomplete. To make type checkers aware of this, the file | ||
can contain the following code:: | ||
|
This is slightly misleading, because it suggests the mechanism may depend on the name
b
in the package namespace. The actual mechanism is that all imported submodules of a package appear as exported attributes of the package. So even ifa/__init__.pyi
contained this:then
b
would become an attribute ofa
. (There's code in the runtime to do this, and a type checker ought to emulate the runtime behavior here.)(FWIW I wouldn't use that example in the PEP text, this is just to explain it to you so you may come up with a reasonable edit to the PEP text.)