Skip to content
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

Use a tuple for processed parameter to facilitate future caching #2529

Merged
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
14 changes: 7 additions & 7 deletions astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, path: Sequence[str] | None = None) -> None:
def find_module(
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
"""Find the given module.
Expand Down Expand Up @@ -130,7 +130,7 @@ class ImportlibFinder(Finder):
def find_module(
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
if submodule_path is not None:
Expand Down Expand Up @@ -225,7 +225,7 @@ class ExplicitNamespacePackageFinder(ImportlibFinder):
def find_module(
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
if processed:
Expand Down Expand Up @@ -265,7 +265,7 @@ def __init__(self, path: Sequence[str]) -> None:
def find_module(
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
try:
Expand All @@ -289,7 +289,7 @@ class PathSpecFinder(Finder):
def find_module(
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
spec = importlib.machinery.PathFinder.find_spec(modname, path=submodule_path)
Expand Down Expand Up @@ -373,7 +373,7 @@ def _find_spec_with_path(
search_path: Sequence[str],
modname: str,
module_parts: tuple[str],
processed: list[str],
processed: tuple[str],
submodule_path: Sequence[str] | None,
) -> tuple[Finder | _MetaPathFinder, ModuleSpec]:
for finder in _SPEC_FINDERS:
Expand Down Expand Up @@ -457,7 +457,7 @@ def _find_spec(module_path: tuple, path: tuple) -> ModuleSpec:
while modpath:
modname = modpath.pop(0)
finder, spec = _find_spec_with_path(
_path, modname, module_parts, processed, submodule_path or path
_path, modname, module_parts, tuple(processed), submodule_path or path
)
processed.append(modname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here

if modpath:
Expand Down
Loading