From 3c71ba4b2a3f7a69e6aad83eea0d9158231713b1 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Thu, 5 Nov 2020 12:20:09 -0500 Subject: [PATCH] Fix wiring multiple imports, issue #320 --- src/dependency_injector/wiring.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dependency_injector/wiring.py b/src/dependency_injector/wiring.py index 1c4fcbf4..362493d9 100644 --- a/src/dependency_injector/wiring.py +++ b/src/dependency_injector/wiring.py @@ -2,6 +2,7 @@ import functools import inspect +import importlib import pkgutil import sys from types import ModuleType @@ -289,11 +290,11 @@ def _resolve_injections( def _fetch_modules(package): modules = [package] - for loader, module_name, is_pkg in pkgutil.walk_packages( + for module_info in pkgutil.walk_packages( path=package.__path__, prefix=package.__name__ + '.', ): - module = loader.find_module(module_name).load_module(module_name) + module = importlib.import_module(module_info.name) modules.append(module) return modules