Skip to content

Commit d8dbc46

Browse files
correctmostjacobtylerwalls
authored andcommitted
Use a tuple for module_parts parameter to facilitate future caching
1 parent f924ba2 commit d8dbc46

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

astroid/interpreter/_import/spec.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self, path: Sequence[str] | None = None) -> None:
9090
@abc.abstractmethod
9191
def find_module(
9292
modname: str,
93-
module_parts: Sequence[str],
93+
module_parts: tuple[str],
9494
processed: list[str],
9595
submodule_path: Sequence[str] | None,
9696
) -> ModuleSpec | None:
@@ -100,7 +100,7 @@ def find_module(
100100
they all return a ModuleSpec.
101101
102102
:param modname: The module which needs to be searched.
103-
:param module_parts: It should be a list of strings,
103+
:param module_parts: It should be a tuple of strings,
104104
where each part contributes to the module's
105105
namespace.
106106
:param processed: What parts from the module parts were processed
@@ -129,7 +129,7 @@ class ImportlibFinder(Finder):
129129
@staticmethod
130130
def find_module(
131131
modname: str,
132-
module_parts: Sequence[str],
132+
module_parts: tuple[str],
133133
processed: list[str],
134134
submodule_path: Sequence[str] | None,
135135
) -> ModuleSpec | None:
@@ -224,7 +224,7 @@ class ExplicitNamespacePackageFinder(ImportlibFinder):
224224
@staticmethod
225225
def find_module(
226226
modname: str,
227-
module_parts: Sequence[str],
227+
module_parts: tuple[str],
228228
processed: list[str],
229229
submodule_path: Sequence[str] | None,
230230
) -> ModuleSpec | None:
@@ -264,7 +264,7 @@ def __init__(self, path: Sequence[str]) -> None:
264264
@staticmethod
265265
def find_module(
266266
modname: str,
267-
module_parts: Sequence[str],
267+
module_parts: tuple[str],
268268
processed: list[str],
269269
submodule_path: Sequence[str] | None,
270270
) -> ModuleSpec | None:
@@ -288,7 +288,7 @@ class PathSpecFinder(Finder):
288288
@staticmethod
289289
def find_module(
290290
modname: str,
291-
module_parts: Sequence[str],
291+
module_parts: tuple[str],
292292
processed: list[str],
293293
submodule_path: Sequence[str] | None,
294294
) -> ModuleSpec | None:
@@ -342,7 +342,7 @@ def _get_zipimporters() -> Iterator[tuple[str, zipimport.zipimporter]]:
342342

343343

344344
def _search_zip(
345-
modpath: Sequence[str],
345+
modpath: tuple[str],
346346
) -> tuple[Literal[ModuleType.PY_ZIPMODULE], str, str]:
347347
for filepath, importer in _get_zipimporters():
348348
if PY310_PLUS:
@@ -372,7 +372,7 @@ def _search_zip(
372372
def _find_spec_with_path(
373373
search_path: Sequence[str],
374374
modname: str,
375-
module_parts: list[str],
375+
module_parts: tuple[str],
376376
processed: list[str],
377377
submodule_path: Sequence[str] | None,
378378
) -> tuple[Finder | _MetaPathFinder, ModuleSpec]:
@@ -451,7 +451,7 @@ def _find_spec(module_path: tuple, path: tuple) -> ModuleSpec:
451451
modpath = list(module_path)
452452

453453
submodule_path = None
454-
module_parts = modpath[:]
454+
module_parts = tuple(modpath)
455455
processed: list[str] = []
456456

457457
while modpath:

0 commit comments

Comments
 (0)