Skip to content

Commit 5212809

Browse files
authored
🐛 fix lazy module finder duty (#89)
1 parent 84c22eb commit 5212809

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

githubkit/lazy_module.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ def find_spec(
106106
path: Optional[Sequence[str]],
107107
target: Optional[ModuleType] = None,
108108
) -> Optional[ModuleSpec]:
109-
module_spec = PathFinder.find_spec(fullname, path, target)
110-
if not module_spec or not module_spec.origin:
111-
return module_spec
109+
if any(re.match(pattern, fullname) for pattern in LAZY_MODULES):
110+
module_spec = PathFinder.find_spec(fullname, path, target)
111+
if not module_spec or not module_spec.origin:
112+
return
112113

113-
if module_spec and any(
114-
re.match(pattern, module_spec.name) for pattern in LAZY_MODULES
115-
):
116114
module_spec.loader = LazyModuleLoader(module_spec.name, module_spec.origin)
117-
return module_spec
115+
return module_spec
118116

119117

120118
def apply():

0 commit comments

Comments
 (0)