Only the first lazy submodule will appear in a package shared by two lazy submodules.
la = lazy_import.lazy_module('package.a')
lb = lazy_import.lazy_module('package.b')
import package
'a' in type(package)._lazy_import_submodules
'b' not in type(package)._lazy_import_submodules
This is because when a cached lazy package is found (https://github.com/mnmelo/lazy_import/blob/master/lazy_import/__init__.py#L378), we don't update the reference of _LazyModule to the cached module and hence the module from the last iteration of the loop has it's `_lazy_import_submodules` attribute updated. Thus resulting in the following:
'b' in type(lb)._lazy_import_submodules
2. After a package is loaded, references to lazy modules are lost, resulting in:
la = lazy_import.lazy_module('package.a')
import package
package.a == la
from package import a !!!! fails !!!!
This problem is rooted here: https://github.com/mnmelo/lazy_import/blob/master/lazy_import/__init__.py#L689
The issue is that prior to reloading the module, we clean all lazy sub-module attributes and LazyModule class attributes. We then try to restore those attributes, but we rely on a class attribute which has been removed. Thus no sub-modules are found and the lazy state isn't restored.
Two issues I am seeing in Python 2.7:
import package 'a' in type(package)._lazy_import_submodules 'b' not in type(package)._lazy_import_submodules
'b' in type(lb)._lazy_import_submodules
la = lazy_import.lazy_module('package.a')
import package package.a == la from package import a !!!! fails !!!!