mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-12-01 05:53:59 +03:00
Refactor the implementation
This commit is contained in:
parent
6ec978d13e
commit
21f98a4e83
File diff suppressed because it is too large
Load Diff
|
@ -4896,9 +4896,10 @@ def isasyncgenfunction(obj):
|
||||||
def _resolve_provides(provides):
|
def _resolve_provides(provides):
|
||||||
if provides is None:
|
if provides is None:
|
||||||
return provides
|
return provides
|
||||||
elif not isinstance(provides, str):
|
|
||||||
|
if not isinstance(provides, str):
|
||||||
return provides
|
return provides
|
||||||
else:
|
|
||||||
segments = provides.split(".")
|
segments = provides.split(".")
|
||||||
member_name = segments[-1]
|
member_name = segments[-1]
|
||||||
|
|
||||||
|
@ -4911,11 +4912,9 @@ def _resolve_provides(provides):
|
||||||
|
|
||||||
module_name = ".".join(segments[:-1])
|
module_name = ".".join(segments[:-1])
|
||||||
|
|
||||||
package_name = None
|
|
||||||
if module_name.startswith("."):
|
|
||||||
package_name = _resolve_calling_package_name()
|
package_name = _resolve_calling_package_name()
|
||||||
if package_name is None:
|
if module_name.startswith(".") and package_name is None:
|
||||||
raise ImportError("attempted relative import with no known parent package")
|
raise ImportError("Attempted relative import with no known parent package")
|
||||||
|
|
||||||
module = importlib.import_module(module_name, package=package_name)
|
module = importlib.import_module(module_name, package=package_name)
|
||||||
return getattr(module, member_name)
|
return getattr(module, member_name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user