Skip to content

Commit

Permalink
Use a tuple for module_parts parameter to facilitate future caching
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored and jacobtylerwalls committed Aug 26, 2024
1 parent f924ba2 commit d8dbc46
Showing 1 changed file with 9 additions and 9 deletions.
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

0 comments on commit d8dbc46

Please sign in to comment.