File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55import contextlib
6+ import copy
67import dataclasses
78import datetime
89import functools
@@ -2146,7 +2147,7 @@ def _replace(
21462147 "fget" : kwargs .pop ("fget" , self ._fget ),
21472148 "initial_value" : kwargs .pop ("initial_value" , self ._initial_value ),
21482149 "cache" : kwargs .pop ("cache" , self ._cache ),
2149- "deps" : kwargs .pop ("deps" , self ._static_deps ),
2150+ "deps" : kwargs .pop ("deps" , copy . copy ( self ._static_deps ) ),
21502151 "auto_deps" : kwargs .pop ("auto_deps" , self ._auto_deps ),
21512152 "interval" : kwargs .pop ("interval" , self ._update_interval ),
21522153 "backend" : kwargs .pop ("backend" , self ._backend ),
Original file line number Diff line number Diff line change @@ -3916,3 +3916,22 @@ class OtherState(rx.State):
39163916
39173917 other_state .data .append ({"foo" : "baz" })
39183918 assert "rows" in comp_state .dirty_vars
3919+
3920+
3921+ def test_computed_var_mutability () -> None :
3922+ class CvMixin (rx .State , mixin = True ):
3923+ @rx .var (cache = True , deps = ["hi" ])
3924+ def cv (self ) -> int :
3925+ return 42
3926+
3927+ class FirstCvState (CvMixin , rx .State ):
3928+ pass
3929+
3930+ class SecondCvState (CvMixin , rx .State ):
3931+ pass
3932+
3933+ first_cv = FirstCvState .computed_vars ["cv" ]
3934+ second_cv = SecondCvState .computed_vars ["cv" ]
3935+
3936+ assert first_cv is not second_cv
3937+ assert first_cv ._static_deps is not second_cv ._static_deps
You can’t perform that action at this time.
0 commit comments