1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Implemented "is_dirty" for Autoserializables, to avoid publication and

This commit is contained in:
Adolfo Gómez García 2024-07-11 10:58:54 +02:00
parent d974d5904c
commit 72407449be
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23

View File

@ -177,10 +177,6 @@ class _ObservableDict(dict[T, V]):
self._owner._dirty = True
return super().popitem()
def setdefault(self, key: T, default: V, /) -> V:
self._owner._dirty = True
return super().setdefault(key, default)
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
self._owner._dirty = True
super().update(*args, **kwargs)
@ -747,6 +743,9 @@ class AutoSerializable(Serializable, metaclass=_FieldNameSetter):
def as_dict(self) -> dict[str, typing.Any]:
return {k: v.__get__(self) for k, v in self._autoserializable_fields()}
def is_dirty(self) -> bool:
return self._dirty or super().is_dirty()
def __eq__(self, other: typing.Any) -> bool:
"""
Basic equality check, checks if all _SerializableFields are equal