epy.lazy_api_imports#
- etils.epy.lazy_api_imports(
- globals_: dict[str, Any],
- *,
- error_msg: str | None = None,
Lazy-import an API (__init__.py).
Usage:
with epy.lazy_api_imports(globals()): from my_project import Obj1 from my_project import OtherObj from my_project import my_function
Contrary to epy.lazy_imports() which works on modules (and resolve the imports) during first access. This function is intended to be used on __init__.py files, such as all imported symbols are lazy and only resolved when the symbol is accessed.
- Parameters:
globals – The module globals(). Will be updated to add a __getattr__
error_msg – A additional message to append to the ImportError if the import fails. Can use {symbol_name} dynamic placeholder.
- Yields:
None