cattrs v22.2.0 Release NotesRelease Date: 2022-10-03 // 4 months ago
- Potentially breaking:
cattrs.Converterhas been renamed to
GenConvertername is still available for backwards compatibility, but is deprecated. If you were depending on functionality specific to the old
Converter, change your import to
from cattrs import BaseConverter.
NewTypes <https://docs.python.org/3/library/typing.html#newtype>_ are now supported by the
cattrs.BaseConvertercan now copy themselves using the
- 👍 Python 3.11 support.
- 👍 cattrs now supports un/structuring
kw_onlyfields on attrs classes into/from dictionaries. (
- ⏪ PyPy support (and tests, using a minimal Hypothesis profile) restored.
- 🛠 Fix propagating the
detailed_validationflag to mapping and counter structuring generators.
typing.Setapplying too broadly when used with the
GenConverter.unstruct_collection_overridesparameter on Python versions below 3.9. Switch to
typing.AbstractSeton those versions to restore the old behavior. (
- 📌 Uncap the required Python version, to avoid problems detailed in https://iscinumpy.dev/post/bound-version-constraints/#pinning-the-python-version-is-special
cattrs.gen.make_dict_unstructure_fntype annotations. (
- 🔦 Expose all error classes in the
cattr.errorsnamespace. Note that it is deprecated, just use
- 🛠 Fix generating structuring functions for types with quotes in the name.
- 🛠 Fix usage of notes for the final version of
PEP 678 <https://peps.python.org/pep-0678/>, supported since
#303 <303 <https://github.com/python-attrs/cattrs/pull/303>)
- Potentially breaking:
Previous changes from v22.1.0
- cattrs now uses the CalVer versioning convention.
- ✅ cattrs now has a detailed validation mode, which is enabled by default. Learn more
here <https://cattrs.readthedocs.io/en/latest/validation.html>_. The old behavior can be restored by creating the converter with
attrsand dataclass structuring is now ~25% faster.
- 🛠 Fix an issue structuring bare
typing.Lists on Pythons lower than 3.9. (
- 🛠 Fix structuring of non-parametrized containers like
list/dict/...on Pythons lower than 3.9. (
- 🛠 Fix structuring bare
typing.Tupleon Pythons lower than 3.9. (
- Fix a wrong
AttributeErrorof an missing
__parameters__attribute. This could happen when inheriting certain generic classes – for example
typing.*classes are affected. (
- 🛠 Fix structuring of
- 🛠 Fix unstructuring all tuples - unannotated, variable-length, homogenous and heterogenous - to
ForbiddenExtraKeyErrorinstead of generic
- 👀 All preconf converters now support
dumpsdirectly. See an example
- 🛠 Fix mappings with byte keys for the orjson, bson and tomlkit converters.