File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -2537,8 +2537,8 @@ def clear_caches(self) -> None:
25372537 if self .cache_dir .exists ():
25382538 rmtree (self .cache_dir )
25392539
2540- if isinstance (self .state_sync , CachingStateSync ):
2541- self .state_sync .clear_cache ()
2540+ if isinstance (self ._state_sync , CachingStateSync ):
2541+ self ._state_sync .clear_cache ()
25422542
25432543 def export_state (
25442544 self ,
Original file line number Diff line number Diff line change @@ -647,6 +647,9 @@ def test_clear_caches(tmp_path: pathlib.Path):
647647 assert not cache_dir .exists ()
648648 assert models_dir .exists ()
649649
650+ # Ensure that we don't initialize a CachingStateSync only to clear its (empty) caches
651+ assert context ._state_sync is None
652+
650653 # Test clearing caches when cache directory doesn't exist
651654 # This should not raise an exception
652655 context .clear_caches ()
You can’t perform that action at this time.
0 commit comments