Skip to content

v1.22

Compare
Choose a tag to compare
@Fatal1ty Fatal1ty released this 15 Jan 01:04
· 976 commits to master since this release

Changes

  • Support for hooks declared in superclasses
class Counter:
    deserialize = 0
    serialize = 0

    @classmethod
    def __pre_deserialize__(cls, d):
        Counter.deserialize += 1
        return d

    def __pre_serialize__(self):
        Counter.serialize += 1
        return self

@dataclass
class Derived(Counter, DataClassDictMixin):
    a: int

obj = Derived.from_dict({"a": 1})
obj.to_dict()

print(Counter.deserialize)  # 1
print(Counter.serialize)  # 1