Publish lazy imported packages on parent

This commit is contained in:
Dino Viehland 2025-09-29 10:25:00 -07:00
parent 781eedb9d4
commit 9be59ecebd
8 changed files with 248 additions and 1 deletions

View file

@ -1359,6 +1359,12 @@ def _find_and_load_unlocked(name, import_):
except AttributeError:
msg = f"Cannot set an attribute on {parent!r} for child module {child!r}"
_warnings.warn(msg, ImportWarning)
# Set attributes to lazy submodules on the module.
try:
_imp._set_lazy_attributes(module, name)
except Exception as e:
msg = f"Cannot set lazy attributes on {name!r}: {e!r}"
_warnings.warn(msg, ImportWarning)
return module