mashumaro

Fast and well tested serialization library

APACHE-2.0 License

Downloads
18.5M
Stars
726
Committers
13

Bot releases are hidden (Show)

mashumaro -

Published by Fatal1ty over 2 years ago

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 (https://github.com/Fatal1ty/mashumaro/issues/68).
  • Fixed using postponed evaluation with parent class (https://github.com/Fatal1ty/mashumaro/issues/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 to extras_require (https://github.com/Fatal1ty/mashumaro/issues/7).
  • Moved DataClassJSONMixin, DataClassMessagePackMixin, DataClassYAMLMixin to mashumaro.mixins.* subpackages.
  • Removed use_bytes, use_enum, use_datetime parameters from DataClassDictMixin methods.
  • Removed encoder and decoder kwargs from to_*, from_* methods of the serialization mixins in order to pass keyword arguments to underlying to_dict, from_dict methods.

You can find migration guide here: https://github.com/Fatal1ty/mashumaro/blob/master/docs/2to3.md.

mashumaro -

Published by Fatal1ty almost 3 years ago

Changes

  • PEP 604 compliance.
  • Fixed that Union[None, X] with None on the first place wasn't treated as Optional[X].
  • Fixed that Union[X, T] where T was resolved to None wasn't treated as Optional[X].
  • Allow using None as the field type (it's considered equivalent to NoneType).
  • Changed the name of NoneType to None in Unions for convenience. In the previous versions you could see Union[int, str, NoneType] instead of Union[int, str, None] if the field was declared as Union[int, str, None].
mashumaro -

Published by Fatal1ty almost 3 years ago

Changes

mashumaro -

Published by Fatal1ty almost 3 years ago

Changes

mashumaro -

Published by Fatal1ty almost 3 years ago

Changes

  • Fixed installing with third-party tool pdistx. See https://github.com/Fatal1ty/mashumaro/issues/60.
  • Fixed serialzation / deserialization override for Union and TypeVar types. See https://github.com/Fatal1ty/mashumaro/issues/61.
  • Fixed the default value of by_alias argument of to_dict method when using serialize_by_alias config option. In the previous versions by_alias argument had a default valueFalse regardless of whether serialize_by_alias config options was used. Now it could be True:
@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}
mashumaro -

Published by Fatal1ty almost 3 years ago

  • Added support for PEP 563 postponed evaluation of annotations. See here for details.
  • Added ability to treat named tuples as dictionaries during serialization/deserialization:
mashumaro -

Published by Fatal1ty about 3 years ago

  • Added support for Python 3.10
  • PEP 585 compliance
  • Added support for TypedDict
  • Added support for typed NamedTuple and untyped namedtuple
  • 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.
mashumaro -

Published by Fatal1ty about 3 years ago

Changes

  • Added extended support for user-defined generic types. See here for details.
mashumaro -

Published by Fatal1ty about 3 years ago

Changes

mashumaro -

Published by Fatal1ty about 3 years ago

Changes

mashumaro -

Published by Fatal1ty about 3 years ago

Changes

  • Fixed broken type_name for Optional types
  • Fixed broken from_dict method when using TypeVar with a bound parameter
mashumaro -

Published by Fatal1ty about 3 years ago

Changes

  • Fixed broken MissingField and InvalidFieldValue exceptions with shortened generic type names
mashumaro -

Published by Fatal1ty about 3 years ago

Changes

  • Added support for TypeVar types. It works like Union under the hood and both constraints and upper bound can be used to specify a variation of types. Similarly to Union it's recommended to place more complex variant types at first place like TypeVar("T", Dict[int, int], List[int]) not TypeVar("T", List[int], Dict[int, int]).
  • Added support for short version of standard generic types without specifying type of objects kept in containers. Now it's possible to use List instead of List[Any] or Dict instead of Dict[Any, Any].
  • Improved string representation of builtin and standard generic types. Now in the error messages you will see int instead of builtins.int or List instead of typing.List.
mashumaro -

Published by Fatal1ty over 3 years ago

Changes

  • Fixed broken serialization of data classes that also inherit another supported serializable class like MutableMapping. See https://github.com/Fatal1ty/mashumaro/issues/48.
  • Fixed broken deserialization of Union type fields in some cases.
mashumaro -

Published by Fatal1ty over 3 years ago

Changes

  • Fixed calling to_dict method of a class that doesn't have omit_none and by_alias keyword arguments added in case it has a field of the type that has these arguments added:
@dataclass
class A(DataClassDictMixin):
    x: Optional[int] = None

    class Config(BaseConfig):
        aliases = {"x": "x_alias"}
        code_generation_options = [
            TO_DICT_ADD_OMIT_NONE_FLAG,
            TO_DICT_ADD_BY_ALIAS_FLAG,
        ]

@dataclass
class B(DataClassDictMixin):
    a: Optional[A] = None

# This caused an exception NameError: name 'omit_none' is not defined
print(B(a=A(1)).to_dict())
mashumaro -

Published by Fatal1ty over 3 years ago

Changes

  • Improved deserialization speed by removing import statements from generated code.
  • Fixed using annotations with self-references. See https://github.com/Fatal1ty/mashumaro/issues/28.
  • Fixed using SerializableType data classes.
  • Fixed getting UnserializableField for data classes without DataClassDictMixin parent.
  • Added a new exception ThirdPartyModuleNotFoundError, that is raised in case you use pendulum or ciso8601 as the deserialization method, but the corresponding package isn't installed.
mashumaro -

Published by Fatal1ty over 3 years ago

Changes

mashumaro -

Published by Fatal1ty over 3 years ago

Changes

mashumaro -

Published by Fatal1ty over 3 years ago

Changes

mashumaro -

Published by Fatal1ty over 3 years ago

Changes