Releases: Fatal1ty/mashumaro
Releases Β· Fatal1ty/mashumaro
v3.0.2
v3.0.1
v3.0
Changes
- Added support for new types:
typing.NewType
typing.Literal
typing_extensions.Literal
typing.Annotated
typing_extensions.Annotated
zoneinfo.ZoneInfo
typing_extensions.OrderedDict
on Python<3.7.2.
- Fixed using field options when using dataclass slots=True on Python 3.10 (#68).
- Fixed using postponed evaluation with parent class (#70).
- Fixed not removing field metadata options for the overridden field without them.
- Fixed serialization of
SerializableType
generic classes. - Added new
pass_through
object that can be used in serialization_strategy and serialize / deserialize options. - Reduced code building time.
- Use encoder and decoder written in C for YAML by default if available.
Backward incompatible changes
- Moved
msgpack
,pyyaml
dependencies toextras_require
(#7). - Moved
DataClassJSONMixin
,DataClassMessagePackMixin
,DataClassYAMLMixin
tomashumaro.mixins.*
subpackages. - Removed
use_bytes
,use_enum
,use_datetime
parameters fromDataClassDictMixin
methods. - Removed encoder and decoder kwargs from
to_*
,from_*
methods of the serialization mixins in order to pass keyword arguments to underlyingto_dict
,from_dict
methods.
You can find migration guide here: https://github.com/Fatal1ty/mashumaro/blob/master/docs/2to3.md.
v2.11
Changes
- PEP 604 compliance.
- Fixed that
Union[None, X]
withNone
on the first place wasn't treated asOptional[X]
. - Fixed that
Union[X, T]
whereT
was resolved toNone
wasn't treated asOptional[X]
. - Allow using
None
as the field type (it's considered equivalent toNoneType
). - Changed the name of
NoneType
toNone
in Unions for convenience. In the previous versions you could seeUnion[int, str, NoneType]
instead ofUnion[int, str, None]
if the field was declared asUnion[int, str, None]
.
v2.10.1
v2.10
v2.9.1
Changes
- Fixed installing with third-party tool pdistx. See #60.
- Fixed serialzation / deserialization override for
Union
andTypeVar
types. See #61. - Fixed the default value of
by_alias
argument ofto_dict
method when usingserialize_by_alias
config option. In the previous versionsby_alias
argument had a default valueFalse
regardless of whetherserialize_by_alias
config options was used. Now it could beTrue
:
@dataclass
class MyClass(DataClassDictMixin):
x: int
class Config(BaseConfig):
aliases = {"x": "x_alias"}
serialize_by_alias = True
code_generation_options = [TO_DICT_ADD_BY_ALIAS_FLAG]
print(MyClass(x=1).to_dict()) # {'x_alias': 1}
print(MyClass(x=1).to_dict(by_alias=False)) # {x': 1}
v2.9
- Added support for PEP 563 postponed evaluation of annotations. See here for details.
- Added ability to treat named tuples as dictionaries during serialization/deserialization:
- new
as_dict
andas_list
serialization and deserialization engines - new
namedtuple_as_dict
config option
- new
v2.8
- Added support for Python 3.10
- PEP 585 compliance
- Added support for
TypedDict
- Added support for typed
NamedTuple
and untypednamedtuple
- Fixed
Tuple
serialization and deserialization. Before 2.8 all values of tuples were deserialized as if they were values of the first type, no matter how many values the tuple was supposed to take. Now the following types are handled correctly:Tuple[int]
,Tuple[int, ...]
,Tuple[int, str]
,Tuple[()]
,Tuple
.