Fix wiring multiple imports, issue #320

This commit is contained in:
Roman Mogylatov 2020-11-05 12:20:09 -05:00
parent 4579e35d33
commit 3c71ba4b2a

View File

@ -2,6 +2,7 @@
import functools import functools
import inspect import inspect
import importlib
import pkgutil import pkgutil
import sys import sys
from types import ModuleType from types import ModuleType
@ -289,11 +290,11 @@ def _resolve_injections(
def _fetch_modules(package): def _fetch_modules(package):
modules = [package] modules = [package]
for loader, module_name, is_pkg in pkgutil.walk_packages( for module_info in pkgutil.walk_packages(
path=package.__path__, path=package.__path__,
prefix=package.__name__ + '.', prefix=package.__name__ + '.',
): ):
module = loader.find_module(module_name).load_module(module_name) module = importlib.import_module(module_info.name)
modules.append(module) modules.append(module)
return modules return modules