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 5 of 11

0.20.3

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

* Update the parsing logic in :func:`as_timedelta` for :class:`timedelta` annotated types
so we now explicitly check the types. If the value is numeric, or if it's a string in a numeric value
like "1.2", we can parse it directly and so avoid calling the :mod:`pytimeparse` module.

0.20.1

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

* Update and refactor docs, doc layout, and the readme.
* Move benchmark tests to the ``benchmarks/`` directory.

0.20.0

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

* Support custom patterns for dates and times, which are parsed (de-serialized) using :meth:`datetime.strptime`.
This allows two approaches to be used, which have complete support in Python 3.7+ currently:

- Using the ``DatePattern``, ``TimePattern``, and ``DateTimePattern`` type annotations,
representing patterned `date`, `time`, and `datetime` objects respectively.

- Use ``Annotated`` to annotate the field as ``list[time]`` for example, and pass
in :func:`Pattern` as an extra.

0.19.0

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

**Features and Improvements**

* Add the option to customize the name of the *tag* key that will be used to
(de)serialize fields that contain dataclasses within ``Union`` types. A new
attribute :attr:`tag_key` in the ``Meta`` config determines the key in the
JSON object that will be used for this purpose, which defaults to ``__tag__`` if not specified.

* Add the ability to *auto-generate* tags for a class - using the name of
the class - if a value for :attr:`tag` is not specified in the ``Meta`` config
for a dataclass that appears within a ``Union`` declaration. A new flag
:attr:`auto_assign_tags` in the ``Meta`` config can be enabled to allow
auto-assigning the class name as a tag.

0.18.0

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

**Breaking Changes**

* The :func:`LoadMeta` and :func:`DumpMeta` helper functions no longer accept
a class type as the first argument; the correct usage now is to invoke the
:meth:`bind_to` method on the ``Meta`` config returned. That is, given a
dataclass :class:`A`, replace the following syntax::

LoadMeta(A, **kwargs)

with a more explicit binding::

LoadMeta(**kwargs).bind_to(A)

* The :func:`asdict` helper function no longer accepts a ``Meta`` config
as an argument. This is to encourage the usage of :func:`LoadMeta` and
:func:`DumpMeta`, as mentioned above. The main impetus for this change is
performance, since the ``Meta`` config for a class only needs to be set up
once using this approach.

* Updated the project status from *Beta* to *Production/Stable*, to signify
that any further breaking changes will result in bumping the major version.

**Features and Improvements**

* Add the :meth:`bind_to` method to the base Meta class,
:class:`BaseJSONWizardMeta`.

* Meta config specified for a main dataclass (i.e. the class passed in to
``from_dict`` and ``to_dict``) now applies recursively to any nested
dataclasses by default. The Meta config from the main class will be
merged with the Meta config for each nested class. Note that this behavior
can be disabled however, with the :attr:`recursive` parameter passed in
to the ``Meta`` config.

* Rename :class:`BaseMeta` to :class:`AbstractMeta`, as the name should be
overall more clearer, since it's actually an abstract class.

0.17.1

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

* ``property_wizard``: Update the metaclass to support `new-style annotations`_,
also via a ``__future__`` import declared at a the top of a module; this allows
`PEP 585`_ and `PEP 604`_ style annotations to be used in Python 3.7 and higher.

Page 5 of 11

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.