Skip to content

Commit 71f5c0c

Browse files
correctmostDanielNoord
authored andcommitted
Do not reassign submodule_path parameters in method bodies
This makes it easier to use less generic annotations with mypy.
1 parent 1495979 commit 71f5c0c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

astroid/interpreter/_import/spec.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def find_module(
134134
submodule_path: Sequence[str] | None,
135135
) -> ModuleSpec | None:
136136
if submodule_path is not None:
137-
submodule_path = list(submodule_path)
137+
search_paths = list(submodule_path)
138138
elif modname in sys.builtin_module_names:
139139
return ModuleSpec(
140140
name=modname,
@@ -159,10 +159,10 @@ def find_module(
159159
)
160160
except ValueError:
161161
pass
162-
submodule_path = sys.path
162+
search_paths = sys.path
163163

164164
suffixes = (".py", ".pyi", importlib.machinery.BYTECODE_SUFFIXES[0])
165-
for entry in submodule_path:
165+
for entry in search_paths:
166166
package_directory = os.path.join(entry, modname)
167167
for suffix in suffixes:
168168
package_file_name = "__init__" + suffix
@@ -231,13 +231,12 @@ def find_module(
231231
if processed:
232232
modname = ".".join([*processed, modname])
233233
if util.is_namespace(modname) and modname in sys.modules:
234-
submodule_path = sys.modules[modname].__path__
235234
return ModuleSpec(
236235
name=modname,
237236
location="",
238237
origin="namespace",
239238
type=ModuleType.PY_NAMESPACE,
240-
submodule_search_locations=submodule_path,
239+
submodule_search_locations=sys.modules[modname].__path__,
241240
)
242241
return None
243242

0 commit comments

Comments
 (0)