cattrs v22.2.0 Release Notes
Release Date: 2022-10-03 // over 3 years ago-
- Potentially breaking:
cattrs.Converterhas been renamed tocattrs.BaseConverter, andcattrs.GenConvertertocattrs.Converter. TheGenConvertername is still available for backwards compatibility, but is deprecated. If you were depending on functionality specific to the oldConverter, change your import tofrom cattrs import BaseConverter. - 📄
NewTypes <https://docs.python.org/3/library/typing.html#newtype>_ are now supported by thecattrs.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.Converterandcattrs.BaseConvertercan now copy themselves using thecopymethod. (#284 <https://github.com/python-attrs/cattrs/pull/284>_)- 👍 Python 3.11 support.
- 👍 cattrs now supports un/structuring
kw_onlyfields 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_validationflag to mapping and counter structuring generators. - Fix
typing.Setapplying too broadly when used with theGenConverter.unstruct_collection_overridesparameter on Python versions below 3.9. Switch totyping.AbstractSeton 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_factoryandcattrs.gen.make_dict_unstructure_fntype annotations. (#281 <https://github.com/python-attrs/cattrs/issues/281>_) - 🔦 Expose all error classes in the
cattr.errorsnamespace. Note that it is deprecated, just usecattrs.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 sinceexceptiongroup>=1.0.0rc4. (#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 withdetailed_validation=False. attrsand dataclass structuring is now ~25% faster.- 🛠 Fix an issue structuring bare
typing.Lists 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.Tupleon Pythons lower than 3.9. (#218 <https://github.com/python-attrs/cattrs/issues/218>_) - Fix a wrong
AttributeErrorof an missing__parameters__attribute. This could happen when inheriting certain generic classes – for exampletyping.*classes are affected. (#217 <https://github.com/python-attrs/cattrs/issues/217>_) - 🛠 Fix structuring of
enum.Enuminstances intyping.Literaltypes. (#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_keysraise customForbiddenExtraKeyErrorinstead of genericException. (#225 <https://github.com/python-attrs/cattrs/pull/225>_) - 👀 All preconf converters now support
loadsanddumpsdirectly. See an examplehere <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>_)