From 525fcbd69ef51d577712950545ba59eb18b9621d Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Thu, 1 Feb 2024 10:43:51 +0000 Subject: [PATCH] :bug: fix lazy module finder duty --- githubkit/lazy_module.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/githubkit/lazy_module.py b/githubkit/lazy_module.py index 1ee57caf0..408081a32 100644 --- a/githubkit/lazy_module.py +++ b/githubkit/lazy_module.py @@ -106,15 +106,13 @@ def find_spec( path: Optional[Sequence[str]], target: Optional[ModuleType] = None, ) -> Optional[ModuleSpec]: - module_spec = PathFinder.find_spec(fullname, path, target) - if not module_spec or not module_spec.origin: - return module_spec + if any(re.match(pattern, fullname) for pattern in LAZY_MODULES): + module_spec = PathFinder.find_spec(fullname, path, target) + if not module_spec or not module_spec.origin: + return - if module_spec and any( - re.match(pattern, module_spec.name) for pattern in LAZY_MODULES - ): module_spec.loader = LazyModuleLoader(module_spec.name, module_spec.origin) - return module_spec + return module_spec def apply():