Dataclass-wizard

Latest version: v0.34.0

Safety actively analyzes 693883 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 7 of 11

0.15.0

-------------------

* Add the ability to skip fields with default values in the serialization
process. A new attribute ``skip_defaults`` in the inner ``Meta`` class
determines whether to skip / omit fields with default values, based on the
``default`` or ``default_factory`` argument to :func:`dataclasses.field`.

* Add the ability to omit fields in the serialization process.

* A new argument ``dump`` added to the :func:`json_key` and :func:`json_field`
helper functions determines whether to exclude the field in the JSON or
dictionary result.
* The :func:`asdict` helper function has similarly been updated to accept a
``exclude`` argument, containing a list of one or more dataclass field
names to exclude from the serialization process.

0.14.2

-------------------

**Bugfixes**

* Dataclass fields that are excluded from the constructor method - i.e. ones
defined like ``field(init=False...)`` - should now be similarly handled in the
de-serialization process.

0.14.1

-------------------

**Bugfixes**

* The :attr:`Meta.tag` field should be updated to a ``ClassVar`` to help
reduce the memory footprint.

0.14.0

-------------------
**Features and Improvements**

* Add the ability to handle de-serialization and serialization of dataclasses
within ``Union`` types. A new attribute ``tag`` in the inner ``Meta`` class
determines the tag name to map to a dataclass, when the dataclass is part
of any ``Union`` types.

* The dump (serialization) process has been reworked to function more like the
load process. That is, it will properly use the :class:`Meta` config for a
dataclass, as well as any custom load hooks for nested dataclasses. Performance
or functionality should not otherwise be affected.

0.13.1

-------------------

**Bugfixes**

* Ensure that :func:`setup_dump_config_for_cls_if_needed` is called for nested
dataclasses, so that custom key mappings for example can be properly applied.

0.13.0

-------------------
**Features and Improvements**

* Add new error class :class:`MissingData`, which is raised when a dataclass field
annotated as a *data class* type has a ``null`` JSON value in the load process.

* Update the :func:`as_int` helper function so that ``float`` values as well as ones encoded
as strings are correctly converted to annotated ``int`` types, i.e. using the
``int(round(float))`` syntax.

* Add :class:`Encoder` and :class:`Decoder` model classes, and properly implement them
in the :class:`JSONWizard` helper methods.

* Decorate the :class:`JSONWizard` helper methods :meth:`from_list`, :meth:`from_dict`,
and :meth:`to_dict` with the ``_alias`` decorator.

**Bugfixes**

* ``property_wizard``: Remove the internal usage of :func:`get_type_hints_with_extras`
for resolving class annotations. This is because ``typing.get_type_hints`` will raise
an error if a class has forward references in any type annotations. Since the usage
is as a metaclass, forward refs can *never* be resolved. So we will instead access
the class ``__annotations`` directly, and for now will ignore any forward references
which are declared.

* Ensure :func:`fromlist` is actually exported at the top level (looks like that
was not the case)

Page 7 of 11

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.