This commit is contained in:
benedikt-bartscher 2025-02-22 16:37:12 +00:00 committed by GitHub
commit 7d0f4c91e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -2093,6 +2093,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
# Never serialize parent_state or substates.
state["__dict__"].pop("parent_state", None)
state["__dict__"].pop("substates", None)
state["__dict__"].pop("dirty_vars", None)
state["__dict__"].pop("dirty_substates", None)
state["__dict__"].pop("_was_touched", None)
# Remove all inherited vars.
for inherited_var_name in self.inherited_vars:
@ -2109,6 +2111,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
"""
state["__dict__"]["parent_state"] = None
state["__dict__"]["substates"] = {}
state["__dict__"]["dirty_vars"] = set()
state["__dict__"]["dirty_substates"] = set()
super().__setstate__(state)
def _check_state_size(

View File

@ -2581,10 +2581,7 @@ def test_mutable_copy(mutable_state: MutableTestState, copy_func: Callable):
assert getattr(ms_copy, attr) is not getattr(mutable_state, attr)
ms_copy.custom.array.append(42)
assert "custom" in ms_copy.dirty_vars
if copy_func is copy.copy:
assert "custom" in mutable_state.dirty_vars
else:
assert not mutable_state.dirty_vars
assert not mutable_state.dirty_vars
@pytest.mark.parametrize(