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 module_parts parameter to facilitate future caching #2516

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
18 changes: 9 additions & 9 deletions astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, path: Sequence[str] | None = None) -> None:
@abc.abstractmethod
def find_module(
modname: str,
module_parts: Sequence[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
Expand All @@ -100,7 +100,7 @@ def find_module(
they all return a ModuleSpec.

:param modname: The module which needs to be searched.
:param module_parts: It should be a list of strings,
:param module_parts: It should be a tuple of strings,
where each part contributes to the module's
namespace.
:param processed: What parts from the module parts were processed
Expand Down Expand Up @@ -129,7 +129,7 @@ class ImportlibFinder(Finder):
@staticmethod
def find_module(
modname: str,
module_parts: Sequence[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
Expand Down Expand Up @@ -224,7 +224,7 @@ class ExplicitNamespacePackageFinder(ImportlibFinder):
@staticmethod
def find_module(
modname: str,
module_parts: Sequence[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
Expand Down Expand Up @@ -264,7 +264,7 @@ def __init__(self, path: Sequence[str]) -> None:
@staticmethod
def find_module(
modname: str,
module_parts: Sequence[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
Expand All @@ -288,7 +288,7 @@ class PathSpecFinder(Finder):
@staticmethod
def find_module(
modname: str,
module_parts: Sequence[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> ModuleSpec | None:
Expand Down Expand Up @@ -342,7 +342,7 @@ def _get_zipimporters() -> Iterator[tuple[str, zipimport.zipimporter]]:


def _search_zip(
modpath: Sequence[str],
modpath: tuple[str],
) -> tuple[Literal[ModuleType.PY_ZIPMODULE], str, str]:
for filepath, importer in _get_zipimporters():
if PY310_PLUS:
Expand Down Expand Up @@ -372,7 +372,7 @@ def _search_zip(
def _find_spec_with_path(
search_path: Sequence[str],
modname: str,
module_parts: list[str],
module_parts: tuple[str],
processed: list[str],
submodule_path: Sequence[str] | None,
) -> tuple[Finder | _MetaPathFinder, ModuleSpec]:
Expand Down Expand Up @@ -451,7 +451,7 @@ def _find_spec(module_path: tuple, path: tuple) -> ModuleSpec:
modpath = list(module_path)

submodule_path = None
module_parts = modpath[:]
module_parts = tuple(modpath)
processed: list[str] = []

while modpath:
Expand Down
Loading