File tree Expand file tree Collapse file tree 3 files changed +39
-18
lines changed Expand file tree Collapse file tree 3 files changed +39
-18
lines changed Original file line number Diff line number Diff line change 1+ # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2+ # For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
3+ # Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
4+
5+ from __future__ import annotations
6+
7+ from typing import TYPE_CHECKING , Any
8+
9+ from pylint .checkers .typecheck import _similar_names
10+ from pylint .checkers .utils import (
11+ class_is_abstract ,
12+ in_for_else_branch ,
13+ infer_all ,
14+ is_overload_stub ,
15+ overridden_method ,
16+ safe_infer ,
17+ unimplemented_abstract_methods ,
18+ )
19+
20+ if TYPE_CHECKING :
21+ from functools import _lru_cache_wrapper
22+
23+
24+ def clear_lru_caches () -> None :
25+ """Clear caches holding references to AST nodes."""
26+ caches_holding_node_references : list [_lru_cache_wrapper [Any ]] = [
27+ class_is_abstract ,
28+ in_for_else_branch ,
29+ infer_all ,
30+ is_overload_stub ,
31+ overridden_method ,
32+ unimplemented_abstract_methods ,
33+ safe_infer ,
34+ _similar_names ,
35+ ]
36+ for lru in caches_holding_node_references :
37+ lru .cache_clear ()
Original file line number Diff line number Diff line change 1616from collections .abc import Callable , Iterable , Iterator
1717from functools import lru_cache , partial
1818from re import Match
19- from typing import TYPE_CHECKING , Any , TypeVar
19+ from typing import TYPE_CHECKING , TypeVar
2020
2121import astroid .objects
2222from astroid import TooManyLevelsError , nodes , util
2828from pylint .constants import TYPING_NEVER , TYPING_NORETURN
2929
3030if TYPE_CHECKING :
31- from functools import _lru_cache_wrapper
3231
3332 from pylint .checkers import BaseChecker
3433
@@ -2327,21 +2326,6 @@ def overridden_method(
23272326 return None # pragma: no cover
23282327
23292328
2330- def clear_lru_caches () -> None :
2331- """Clear caches holding references to AST nodes."""
2332- caches_holding_node_references : list [_lru_cache_wrapper [Any ]] = [
2333- class_is_abstract ,
2334- in_for_else_branch ,
2335- infer_all ,
2336- is_overload_stub ,
2337- overridden_method ,
2338- unimplemented_abstract_methods ,
2339- safe_infer ,
2340- ]
2341- for lru in caches_holding_node_references :
2342- lru .cache_clear ()
2343-
2344-
23452329def is_enum_member (node : nodes .AssignName ) -> bool :
23462330 """Return `True` if `node` is an Enum member (is an item of the
23472331 `__members__` container).
Original file line number Diff line number Diff line change 1212from typing import ClassVar
1313
1414from pylint import config
15- from pylint .checkers .utils import clear_lru_caches
15+ from pylint .checkers .clear_lru_cache import clear_lru_caches
1616from pylint .config ._pylint_config import (
1717 _handle_pylint_config_commands ,
1818 _register_generate_config_options ,
You can’t perform that action at this time.
0 commit comments