Refactor the implementation

This commit is contained in:
Roman Mogylatov 2022-01-29 22:30:18 -05:00
parent 6ec978d13e
commit 21f98a4e83
2 changed files with 408 additions and 431 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4896,9 +4896,10 @@ def isasyncgenfunction(obj):
def _resolve_provides(provides):
if provides is None:
return provides
elif not isinstance(provides, str):
if not isinstance(provides, str):
return provides
else:
segments = provides.split(".")
member_name = segments[-1]
@ -4911,11 +4912,9 @@ def _resolve_provides(provides):
module_name = ".".join(segments[:-1])
package_name = None
if module_name.startswith("."):
package_name = _resolve_calling_package_name()
if package_name is None:
raise ImportError("attempted relative import with no known parent package")
if module_name.startswith(".") and package_name is None:
raise ImportError("Attempted relative import with no known parent package")
module = importlib.import_module(module_name, package=package_name)
return getattr(module, member_name)