This commit is contained in:
Benedikt Bartscher 2024-12-05 15:41:26 +01:00
parent c721227a06
commit 02dd4a1313
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View File

@ -1288,6 +1288,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
return
if name in self.backend_vars:
if self._backend_vars.get(name) == value:
return
print(f"Setting {name} to {value}.")
self._backend_vars.__setitem__(name, value)
self.dirty_vars.add(name)
self._mark_dirty()
@ -1323,6 +1326,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
)
# Set the attribute.
current_value = getattr(self, name, None)
if current_value == value:
return
super().__setattr__(name, value)
# Add the var to the dirty list.

View File

@ -2164,6 +2164,7 @@ class ComputedVar(Var[RETURN_TYPE]):
Args:
instance: the state instance that needs to recompute the value.
"""
print(f"Marking {self._js_expr} as dirty")
with contextlib.suppress(AttributeError):
delattr(instance, self._cache_attr)