Skip to content

Fix: lazy module finder beyond duty #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions githubkit/lazy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down