Skip to content

v1.15

Compare
Choose a tag to compare
@Fatal1ty Fatal1ty released this 21 Nov 15:19
· 1072 commits to master since this release

Fix for derived data classes with fields and default_factory in ancestors

In the previous versions if a data class had been derived from another data class with a default_factory, MissingField would have been raised on instantiation without field value provided as it shown in the following example:

@dataclass()
class A(DataClassJSONMixin):
    foo: List[str] = field(default_factory=list)
 
@dataclass()
class B(A):
    pass

print(B.from_dict({}))  # MissingField: Field "foo" of type typing.List[str] is missing in __main__.B instance

Thanks to @ian-sentropy who found this bug.