Add a context manager importlib.eager_imports() to make imports in it shallow eager.
Test Plan
I followed the functional spec of importlib.eager_imports() in PEP690 to implement this. Imports within context managers are always eager no matter with or without -L, so I built a null context manger for mportlib.eager_imports().
However, the context manager does not force all imports to be recursively eager. The (sub) imports in the imported module in context manager's scope will still be lazy if Lazy Imports is enabled.
Pre-req
Create test.py, foo.py and bar.py under the same path of python.exe.
Summary
Add a context manager
importlib.eager_imports()
to make imports in it shallow eager.Test Plan
I followed the functional spec of
importlib.eager_imports()
in PEP690 to implement this. Imports within context managers are always eager no matter with or without-L
, so I built a null context manger formportlib.eager_imports()
.However, the context manager does not force all imports to be recursively eager. The (sub) imports in the imported module in context manager's scope will still be lazy if Lazy Imports is enabled.
Pre-req
Create
test.py
,foo.py
andbar.py
under the same path ofpython.exe
.test.py
foo.py
bar.py
Test with Lazy Imports
Run
Expected results:
bar
wasn't eagerly imported because the context managereager_imports()
only madeimport foo
shallow eager.Test without Lazy Imports
Run
Expected results:
bar
was also eagerly imported because we did not use Lazy Imports.