File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -948,13 +948,17 @@ Python versions older than 3.15 while leveraging lazy imports on 3.15+::
948948 import pathlib # loaded lazily
949949
950950Relative imports are resolved to their absolute name before the lookup, so
951- the sequence must always contain fully qualified module names::
951+ the sequence must always contain fully qualified module names. For
952+ ``from ``-style imports, the name to list is the module being imported
953+ *from * (the base module, left of the ``import `` keyword), not the names
954+ imported from it::
952955
953956 # In mypackage/mymodule.py
954- __lazy_modules__ = ["mypackage"]
957+ __lazy_modules__ = ["mypackage", "mypackage.sub.utils" ]
955958
956- from . import utils # loaded lazily: resolves to mypackage
957- import json # loaded eagerly (not in __lazy_modules__)
959+ from . import helper # loaded lazily: . resolves to mypackage
960+ from .sub.utils import func # loaded lazily: .sub.utils resolves to mypackage.sub.utils
961+ import json # loaded eagerly (not in __lazy_modules__)
958962
959963Imports inside functions, class bodies, or
960964:keyword: `try `/:keyword: `except `/:keyword: `finally ` blocks are always eager,
You can’t perform that action at this time.
0 commit comments