Skip to content

Commit 0baeb3c

Browse files
authored
🐛 fix lazy module finder beyond duty
1 parent 9c56950 commit 0baeb3c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

nonebot/adapters/github/lazy_module.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@ def find_spec(
9999
path: Optional[Sequence[str]],
100100
target: Optional[ModuleType] = None,
101101
) -> Optional[ModuleSpec]:
102-
module_spec = PathFinder.find_spec(fullname, path, target)
103-
if not module_spec or not module_spec.origin:
104-
return module_spec
102+
if any(re.match(pattern, fullname) for pattern in LAZY_MODULES):
103+
module_spec = PathFinder.find_spec(fullname, path, target)
104+
if not module_spec or not module_spec.origin:
105+
return
105106

106-
if module_spec and any(
107-
re.match(pattern, module_spec.name) for pattern in LAZY_MODULES
108-
):
109107
module_spec.loader = LazyModuleLoader(module_spec.name, module_spec.origin)
110-
return module_spec
108+
return module_spec
111109

112110

113111
def apply():

0 commit comments

Comments
 (0)