Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add a bound to the inference tips cache (#1565)" #1570

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
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
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