Skip to content

Commit cc546b9

Browse files
committed
Add typing to spec cache
1 parent 2dfce27 commit cc546b9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

astroid/interpreter/_import/spec.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import types
1616
import warnings
1717
import zipimport
18-
from collections.abc import Iterator, Sequence
18+
from collections.abc import Callable, Iterator, Sequence
1919
from pathlib import Path
2020
from typing import Any, Literal, NamedTuple, Protocol
2121

@@ -24,10 +24,10 @@
2424

2525
from . import util
2626

27-
_spec_cache = {}
27+
_spec_cache: dict[str, ModuleSpec] = {}
2828

2929

30-
def clear_spec_cache():
30+
def clear_spec_cache() -> None:
3131
_spec_cache.clear()
3232

3333

@@ -429,11 +429,11 @@ def _find_spec_with_path(
429429
raise ImportError(f"No module named {'.'.join(module_parts)}")
430430

431431

432-
def spec_cache(func):
433-
def wrapper(*args):
434-
key = ".".join(args[0])
432+
def spec_cache(func: Callable) -> Callable:
433+
def wrapper(modpath: list[str], *args) -> ModuleSpec:
434+
key = ".".join(modpath)
435435
if key not in _spec_cache:
436-
_spec_cache[key] = func(*args)
436+
_spec_cache[key] = func(modpath, *args)
437437

438438
return _spec_cache[key]
439439

0 commit comments

Comments
 (0)