Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions astroid/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
"""Various context related utilities, including inference and call contexts."""
import contextlib
import pprint
from typing import TYPE_CHECKING, List, MutableMapping, Optional, Sequence, Tuple
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple

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

_InferenceCache = Dict[
Tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"]
]

_INFERENCE_CACHE = {}
_INFERENCE_CACHE: _InferenceCache = {}


def _invalidate_cache():
def _invalidate_cache() -> None:
_INFERENCE_CACHE.clear()


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

@property
def inferred(
self,
) -> MutableMapping[
Tuple["NodeNG", Optional[str], Optional[str], Optional[str]], Sequence["NodeNG"]
]:
def inferred(self) -> _InferenceCache:
"""
Inferred node contexts to their mapped results

Expand Down Expand Up @@ -164,10 +163,10 @@ def __init__(
):
self.args = args # Call positional arguments
if keywords:
keywords = [(arg.arg, arg.value) for arg in keywords]
arg_value_pairs = [(arg.arg, arg.value) for arg in keywords]
else:
keywords = []
self.keywords = keywords # Call keyword arguments
arg_value_pairs = []
self.keywords = arg_value_pairs # Call keyword arguments
self.callee = callee # Function being called


Expand Down