File tree 3 files changed +9
-2
lines changed 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ Release date: TBA
19
19
20
20
Refs PyCQA/pylint#5288
21
21
22
+ * ``AstroidManager.clear_cache`` now also clears the inference context cache.
23
+
24
+ Refs #1780
25
+
22
26
* ``Astroid`` now retrieves the default values of keyword only arguments and sets them on
23
27
``Arguments.kw_defaults``.
24
28
Original file line number Diff line number Diff line change 20
20
from astroid import nodes
21
21
from astroid ._cache import CACHE_MANAGER
22
22
from astroid .const import BRAIN_MODULES_DIRECTORY
23
- from astroid .context import InferenceContext
23
+ from astroid .context import InferenceContext , _invalidate_cache
24
24
from astroid .exceptions import AstroidBuildingError , AstroidImportError
25
25
from astroid .interpreter ._import import spec , util
26
26
from astroid .modutils import (
@@ -407,7 +407,7 @@ def bootstrap(self) -> None:
407
407
raw_building ._astroid_bootstrapping ()
408
408
409
409
def clear_cache (self ) -> None :
410
- """Clear the underlying cache , bootstrap the builtins module and
410
+ """Clear the underlying caches , bootstrap the builtins module and
411
411
re-register transforms.
412
412
"""
413
413
# import here because of cyclic imports
@@ -418,6 +418,7 @@ def clear_cache(self) -> None:
418
418
from astroid .nodes .scoped_nodes import ClassDef
419
419
420
420
clear_inference_tip_cache ()
421
+ _invalidate_cache () # inference context cache
421
422
422
423
self .astroid_cache .clear ()
423
424
# NB: not a new TransformVisitor()
Original file line number Diff line number Diff line change @@ -430,6 +430,8 @@ def test_clear_cache_clears_other_lru_caches(self) -> None:
430
430
431
431
astroid .MANAGER .clear_cache () # also calls bootstrap()
432
432
433
+ self .assertEqual (astroid .context ._INFERENCE_CACHE , {})
434
+
433
435
# The cache sizes are now as low or lower than the original baseline
434
436
cleared_cache_infos = [lru .cache_info () for lru in lrus ]
435
437
for cleared_cache , baseline_cache in zip (
You can’t perform that action at this time.
0 commit comments