Skip to content

Commit 7221386

Browse files
JelleZijlstragvanrossum
authored andcommitted
PEP 484: Clarify that submodules in a package are exported (#309)
See discussion in python/typeshed#1484 (comment).
1 parent f09b893 commit 7221386

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎pep-0484.txt‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,19 @@ Additional notes on stub files:
16591659
exported. (This makes it easier to re-export all objects from a
16601660
given module that may vary by Python version.)
16611661

1662+
* Just like in normal Python files [importdocs]_, submodules
1663+
automatically become exported attributes of their parent module
1664+
when imported. For example, if the ``spam`` package has the
1665+
following directory structure::
1666+
1667+
spam/
1668+
__init__.pyi
1669+
ham.pyi
1670+
1671+
where ``__init__.pyi`` contains a line such as ``from . import ham``
1672+
or ``from .ham import Ham``, then ``ham`` is an exported attribute
1673+
of ``spam``.
1674+
16621675
* Stub files may be incomplete. To make type checkers aware of this, the file
16631676
can contain the following code::
16641677

@@ -2457,6 +2470,9 @@ References
24572470
.. [peps]
24582471
https://hg.python.org/peps/file/tip/pep-0484.txt
24592472

2473+
.. [importdocs]
2474+
https://docs.python.org/3/reference/import.html#submodules
2475+
24602476

24612477
Copyright
24622478
=========

0 commit comments

Comments
 (0)