[compat_utils] Improve passthrough_module
This commit is contained in:
parent
f6a765ceb5
commit
88426d9446
3 changed files with 18 additions and 24 deletions
|
|
@ -1,10 +1,6 @@
|
|||
import importlib
|
||||
|
||||
from ..compat import functools
|
||||
from ..compat.compat_utils import EnhancedModule, passthrough_module
|
||||
|
||||
EnhancedModule(__name__)
|
||||
|
||||
try:
|
||||
import Cryptodome as _parent
|
||||
except ImportError:
|
||||
|
|
@ -14,14 +10,8 @@ except ImportError:
|
|||
_parent = EnhancedModule('Cryptodome')
|
||||
__bool__ = lambda: False
|
||||
|
||||
|
||||
@functools.cache
|
||||
def __getattr__(name):
|
||||
try:
|
||||
submodule = importlib.import_module(f'.{name}', _parent.__name__)
|
||||
except ImportError:
|
||||
return getattr(_parent, name)
|
||||
return passthrough_module(f'{__name__}.{name}', submodule)
|
||||
passthrough_module(__name__, _parent, (..., '__version__'))
|
||||
del passthrough_module, EnhancedModule
|
||||
|
||||
|
||||
@property
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue