cattrs v22.2.0 Release Notes
Release Date: 2022-10-03 // over 2 years ago-
- Potentially breaking:
cattrs.Converter
has been renamed tocattrs.BaseConverter
, andcattrs.GenConverter
tocattrs.Converter
. TheGenConverter
name 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.Converter
andcattrs.BaseConverter
can now copy themselves using thecopy
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 theGenConverter.unstruct_collection_overrides
parameter on Python versions below 3.9. Switch totyping.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
andcattrs.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 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
. 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 exampletyping.*
classes are affected. (#217 <https://github.com/python-attrs/cattrs/issues/217>
_) - ๐ Fix structuring of
enum.Enum
instances intyping.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 customForbiddenExtraKeyError
instead of genericException
. (#225 <https://github.com/python-attrs/cattrs/pull/225>
_) - ๐ All preconf converters now support
loads
anddumps
directly. 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>
_)