File tree 1 file changed +9
-7
lines changed
astroid/interpreter/_import 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 15
15
import types
16
16
import warnings
17
17
import zipimport
18
- from collections .abc import Iterator , Sequence
18
+ from collections .abc import Callable , Iterator , Sequence
19
19
from pathlib import Path
20
20
from typing import Any , Literal , NamedTuple , Protocol
21
21
24
24
25
25
from . import util
26
26
27
- _spec_cache = {}
27
+ _spec_cache : dict [ str , ModuleSpec ] = {}
28
28
29
29
30
- def clear_spec_cache ():
30
+ def clear_spec_cache () -> None :
31
31
_spec_cache .clear ()
32
32
33
33
@@ -429,11 +429,13 @@ def _find_spec_with_path(
429
429
raise ImportError (f"No module named { '.' .join (module_parts )} " )
430
430
431
431
432
- def spec_cache (func ):
433
- def wrapper (* args ):
434
- key = "." .join (args [0 ])
432
+ def spec_cache (
433
+ func : Callable [[list [str ], Sequence [str ] | None ], ModuleSpec ]
434
+ ) -> Callable [..., ModuleSpec ]:
435
+ def wrapper (modpath : list [str ], * args ) -> ModuleSpec :
436
+ key = "." .join (modpath )
435
437
if key not in _spec_cache :
436
- _spec_cache [key ] = func (* args )
438
+ _spec_cache [key ] = func (modpath , * args )
437
439
438
440
return _spec_cache [key ]
439
441
You can’t perform that action at this time.
0 commit comments