improve plugin finder

This commit is contained in:
yanyongyu 2022-01-26 20:55:23 +08:00
parent 770e808f1d
commit 0885474b94
No known key found for this signature in database
GPG Key ID: 796D8A7FB73396EB

View File

@ -138,7 +138,6 @@ class PluginFinder(MetaPathFinder):
target: Optional[ModuleType] = None,
):
if _managers:
index = -1
module_spec = PathFinder.find_spec(fullname, path, target)
if not module_spec:
return
@ -147,17 +146,13 @@ class PluginFinder(MetaPathFinder):
return
module_path = Path(module_origin).resolve()
while -index <= len(_managers):
manager = _managers[index]
for manager in reversed(_managers):
if (
fullname in manager.plugins
or module_path in manager.searched_plugins.values()
):
module_spec.loader = PluginLoader(manager, fullname, module_origin)
return module_spec
index -= 1
return