PEP 484: Clarify that submodules in a package are exported (#309)

See discussion in https://github.com/python/typeshed/pull/1484#discussion_r127114355.
This commit is contained in:
Jelle Zijlstra 2017-07-17 15:51:21 -07:00 committed by Guido van Rossum
parent f09b893072
commit 7221386f27
1 changed files with 16 additions and 0 deletions

View File

@ -1659,6 +1659,19 @@ Additional notes on stub files:
exported. (This makes it easier to re-export all objects from a 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.)
* Just like in normal Python files [importdocs]_, submodules
automatically become exported attributes of their parent module
when imported. For example, if the ``spam`` package has the
following directory structure::
spam/
__init__.pyi
ham.pyi
where ``__init__.pyi`` contains a line such as ``from . import ham``
or ``from .ham import Ham``, then ``ham`` is an exported attribute
of ``spam``.
* Stub files may be incomplete. To make type checkers aware of this, the file * Stub files may be incomplete. To make type checkers aware of this, the file
can contain the following code:: can contain the following code::
@ -2457,6 +2470,9 @@ References
.. [peps] .. [peps]
https://hg.python.org/peps/file/tip/pep-0484.txt https://hg.python.org/peps/file/tip/pep-0484.txt
.. [importdocs]
https://docs.python.org/3/reference/import.html#submodules
Copyright Copyright
========= =========