Skip to content

Commit 014a04c

Browse files
authored
Fix typing in context.py (#1471)
1 parent bedb3ed commit 014a04c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

astroid/context.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
"""Various context related utilities, including inference and call contexts."""
66
import contextlib
77
import pprint
8-
from typing import TYPE_CHECKING, List, MutableMapping, Optional, Sequence, Tuple
8+
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple
99

1010
if TYPE_CHECKING:
1111
from astroid.nodes.node_classes import Keyword, NodeNG
1212

13+
_InferenceCache = Dict[
14+
Tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"]
15+
]
1316

14-
_INFERENCE_CACHE = {}
17+
_INFERENCE_CACHE: _InferenceCache = {}
1518

1619

17-
def _invalidate_cache():
20+
def _invalidate_cache() -> None:
1821
_INFERENCE_CACHE.clear()
1922

2023

@@ -96,11 +99,7 @@ def nodes_inferred(self, value):
9699
self._nodes_inferred[0] = value
97100

98101
@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:
104103
"""
105104
Inferred node contexts to their mapped results
106105
@@ -164,10 +163,10 @@ def __init__(
164163
):
165164
self.args = args # Call positional arguments
166165
if keywords:
167-
keywords = [(arg.arg, arg.value) for arg in keywords]
166+
arg_value_pairs = [(arg.arg, arg.value) for arg in keywords]
168167
else:
169-
keywords = []
170-
self.keywords = keywords # Call keyword arguments
168+
arg_value_pairs = []
169+
self.keywords = arg_value_pairs # Call keyword arguments
171170
self.callee = callee # Function being called
172171

173172

0 commit comments

Comments
 (0)