Skip to content

Commit

Permalink
Revert "Add a bound to the inference tips cache (#1565)" (#1570)
Browse files Browse the repository at this point in the history
This reverts commit 95bbd5e.
  • Loading branch information
jacobtylerwalls authored May 17, 2022
1 parent cc37d58 commit 33b6c56
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
4 changes: 0 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ Release date: TBA

Refs PyCQA/pylint#5113

* Add a bound to the inference tips cache.

Closes #1150

* Infer the return value of the ``.copy()`` method on ``dict``, ``list``, ``set``,
and ``frozenset``.

Expand Down
6 changes: 1 addition & 5 deletions astroid/inference_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

import typing
from collections import OrderedDict
from collections.abc import Iterator

import wrapt
Expand All @@ -21,7 +20,7 @@
NodeNG, bases.Instance, bases.UnboundMethod, typing.Type[util.Uninferable]
]

_cache: OrderedDict[tuple[InferFn, NodeNG], list[InferOptions] | None] = OrderedDict()
_cache: dict[tuple[InferFn, NodeNG], list[InferOptions] | None] = {}


def clear_inference_tip_cache():
Expand All @@ -37,14 +36,11 @@ def _inference_tip_cached(
node = args[0]
try:
result = _cache[func, node]
_cache.move_to_end((func, node))
# If through recursion we end up trying to infer the same
# func + node we raise here.
if result is None:
raise UseInferenceDefault()
except KeyError:
if len(_cache) > 127:
_cache.popitem(last=False)
_cache[func, node] = None
result = _cache[func, node] = list(func(*args, **kwargs))
assert result
Expand Down

0 comments on commit 33b6c56

Please sign in to comment.