From 0885474b94e99113433e504165d06cde0abba9a6 Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 26 Jan 2022 20:55:23 +0800 Subject: [PATCH] :zap: improve plugin finder --- nonebot/plugin/manager.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nonebot/plugin/manager.py b/nonebot/plugin/manager.py index 260ce9fc..7e8b2826 100644 --- a/nonebot/plugin/manager.py +++ b/nonebot/plugin/manager.py @@ -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