Releases: Fatal1ty/mashumaro
v1.18
v1.17
Changes
- Support for all types from
pathlib
- Variable annotated with a class derived from
os.PathLike
will be deserialized into an instance of that class - Variable annotated with
os.PathLike
will be deserialized into an instance ofPurePath
class:PurePosixClass
on posix,PureWindowsPath
in windows
v1.16
v1.15
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.
v1.14
v1.13
Fix for custom Enum serializable classes
In the version 1.12
if you inherit both Enum
and SerializableType
classes you will get an exception TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
like in the following example:
class Example(IntEnum, SerializableType):
A = 1
B = 2
def _serialize(self):
return {"value": self.name}
@classmethod
def _deserialize(cls, value):
return Example.__members__[value["value"]]
v1.12
Fix for derived data classes without annotations
In the version 1.11
if a data class without annotations had been derived from another data class, KeyError
would have been raised as it shown in the following example:
@dataclass
class A:
a: int
@dataclass
class B(A, DataClassDictMixin):
pass
# ...
# KeyError: '__annotations__'
v1.11
Fix constructing data class instances with inherited default values
In the previous versions there was a problem in case one data class is derived from another data class that have default values. If any ancestor had had a field with a default value, constructing an instance from a dictionary without that field would've been failed as it shown in the following example:
@dataclass
class A:
a: int
b: int = 123
@dataclass
class B(A, DataClassDictMixin):
c: int = 456
B.from_dict({'a': 111, 'c': 222}) # mashumaro.exceptions.MissingField: Field "b" of type builtins.int is missing in __main__.B instance