|
5 | 5 | """Various context related utilities, including inference and call contexts."""
|
6 | 6 | import contextlib
|
7 | 7 | import pprint
|
8 |
| -from typing import TYPE_CHECKING, List, MutableMapping, Optional, Sequence, Tuple |
| 8 | +from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple |
9 | 9 |
|
10 | 10 | if TYPE_CHECKING:
|
11 | 11 | from astroid.nodes.node_classes import Keyword, NodeNG
|
12 | 12 |
|
| 13 | +_InferenceCache = Dict[ |
| 14 | + Tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"] |
| 15 | +] |
13 | 16 |
|
14 |
| -_INFERENCE_CACHE = {} |
| 17 | +_INFERENCE_CACHE: _InferenceCache = {} |
15 | 18 |
|
16 | 19 |
|
17 |
| -def _invalidate_cache(): |
| 20 | +def _invalidate_cache() -> None: |
18 | 21 | _INFERENCE_CACHE.clear()
|
19 | 22 |
|
20 | 23 |
|
@@ -96,11 +99,7 @@ def nodes_inferred(self, value):
|
96 | 99 | self._nodes_inferred[0] = value
|
97 | 100 |
|
98 | 101 | @property
|
99 |
| - def inferred( |
100 |
| - self, |
101 |
| - ) -> MutableMapping[ |
102 |
| - Tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"] |
103 |
| - ]: |
| 102 | + def inferred(self) -> _InferenceCache: |
104 | 103 | """
|
105 | 104 | Inferred node contexts to their mapped results
|
106 | 105 |
|
@@ -164,10 +163,10 @@ def __init__(
|
164 | 163 | ):
|
165 | 164 | self.args = args # Call positional arguments
|
166 | 165 | if keywords:
|
167 |
| - keywords = [(arg.arg, arg.value) for arg in keywords] |
| 166 | + arg_value_pairs = [(arg.arg, arg.value) for arg in keywords] |
168 | 167 | else:
|
169 |
| - keywords = [] |
170 |
| - self.keywords = keywords # Call keyword arguments |
| 168 | + arg_value_pairs = [] |
| 169 | + self.keywords = arg_value_pairs # Call keyword arguments |
171 | 170 | self.callee = callee # Function being called
|
172 | 171 |
|
173 | 172 |
|
|
0 commit comments