cattrs v22.2.0 Release Notes

Release Date: 2022-10-03 // 4 months ago
    • Potentially breaking: cattrs.Converter has been renamed to cattrs.BaseConverter, and cattrs.GenConverter to cattrs.Converter. The GenConverter name 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.Converter. (#255 <https://github.com/python-attrs/cattrs/pull/255>, #94 <https://github.com/python-attrs/cattrs/issues/94>, #297 <https://github.com/python-attrs/cattrs/issues/297>_)
    • cattrs.Converter and cattrs.BaseConverter can now copy themselves using the copy method. (#284 <https://github.com/python-attrs/cattrs/pull/284>_)
    • ๐Ÿ‘ Python 3.11 support.
    • ๐Ÿ‘ cattrs now supports un/structuring kw_only fields on attrs classes into/from dictionaries. (#247 <https://github.com/python-attrs/cattrs/pull/247>_)
    • โช PyPy support (and tests, using a minimal Hypothesis profile) restored. (#253 <https://github.com/python-attrs/cattrs/issues/253>_)
    • ๐Ÿ›  Fix propagating the detailed_validation flag to mapping and counter structuring generators.
    • Fix typing.Set applying too broadly when used with the GenConverter.unstruct_collection_overrides parameter on Python versions below 3.9. Switch to typing.AbstractSet on those versions to restore the old behavior. (#264 <https://github.com/python-attrs/cattrs/issues/264>_)
    • ๐Ÿ“Œ Uncap the required Python version, to avoid problems detailed in https://iscinumpy.dev/post/bound-version-constraints/#pinning-the-python-version-is-special (#275 <https://github.com/python-attrs/cattrs/issues/275>_)
    • Fix Converter.register_structure_hook_factory and cattrs.gen.make_dict_unstructure_fn type annotations. (#281 <https://github.com/python-attrs/cattrs/issues/281>_)
    • ๐Ÿ”ฆ Expose all error classes in the cattr.errors namespace. Note that it is deprecated, just use cattrs.errors. (#252 <https://github.com/python-attrs/cattrs/issues/252>_)
    • ๐Ÿ›  Fix generating structuring functions for types with quotes in the name. (#291 <https://github.com/python-attrs/cattrs/issues/291>_ #277 <https://github.com/python-attrs/cattrs/issues/277>_)
    • ๐Ÿ›  Fix usage of notes for the final version of PEP 678 <https://peps.python.org/pep-0678/>, supported since exceptiongroup>=1.0.0rc4. (#303 <303 <https://github.com/python-attrs/cattrs/pull/303>)

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 detailed_validation=False.
    • attrs and dataclass structuring is now ~25% faster.
    • ๐Ÿ›  Fix an issue structuring bare typing.List s on Pythons lower than 3.9. (#209 <https://github.com/python-attrs/cattrs/issues/209>_)
    • ๐Ÿ›  Fix structuring of non-parametrized containers like list/dict/... on Pythons lower than 3.9. (#218 <https://github.com/python-attrs/cattrs/issues/218>_)
    • ๐Ÿ›  Fix structuring bare typing.Tuple on Pythons lower than 3.9. (#218 <https://github.com/python-attrs/cattrs/issues/218>_)
    • Fix a wrong AttributeError of an missing __parameters__ attribute. This could happen when inheriting certain generic classes โ€“ for example typing.* classes are affected. (#217 <https://github.com/python-attrs/cattrs/issues/217>_)
    • ๐Ÿ›  Fix structuring of enum.Enum instances in typing.Literal types. (#231 <https://github.com/python-attrs/cattrs/pull/231>_)
    • ๐Ÿ›  Fix unstructuring all tuples - unannotated, variable-length, homogenous and heterogenous - to list. (#226 <https://github.com/python-attrs/cattrs/issues/226>_)
    • For forbid_extra_keys raise custom ForbiddenExtraKeyError instead of generic Exception. (#225 <https://github.com/python-attrs/cattrs/pull/225>_)
    • ๐Ÿ‘€ All preconf converters now support loads and dumps directly. See an example here <https://cattrs.readthedocs.io/en/latest/preconf.html>_.
    • ๐Ÿ›  Fix mappings with byte keys for the orjson, bson and tomlkit converters. (#241 <https://github.com/python-attrs/cattrs/issues/241>_)