- Potentially breaking: The converters raise
StructureHandlerNotFoundError
more eagerly (on hook creation, instead of on hook use). This helps surfacing problems with missing hooks sooner. See Migrations for steps to restore legacy behavior.
(#577) - Add a Migrations page, with instructions on migrating changed behavior for each version.
(#577) typing.Self
is now supported in attrs classes, dataclasses, TypedDicts and the dict NamedTuple factories. Seetyping.Self
for details.
(#299 #627)- PEP 695 type aliases can now be used with
BaseConverter.register_structure_hook
andBaseConverter.register_unstructure_hook
. Previously, they required the use ofBaseConverter.register_structure_hook_func
(which is still supported).
(#647) - Expose
cattrs.cols.mapping_unstructure_factory
throughcattrs.cols
. - Some
defaultdicts
are now supported by default, and
cattrs.cols.is_defaultdict
andcattrs.cols.defaultdict_structure_factory
are exposed throughcattrs.cols
.
(#519 #588) - Generic PEP 695 type aliases are now supported.
(#611 #618) - The tagged union strategy now also supports type aliases of unions.
(#649) Converter.copy
andBaseConverter.copy
are correctly annotated as returningSelf
.
(#644)- Many preconf converters (bson, stdlib JSON, cbor2, msgpack, msgspec, orjson, ujson) skip unstructuring
int
andstr
enums, leaving them to the underlying libraries to handle with greater efficiency.
(#598) - The msgspec JSON preconf converter now handles dataclasses with private attributes more efficiently.
(#624) - Literals containing enums are now unstructured properly, and their unstructuring is greatly optimized in the bson, stdlib JSON, cbor2, msgpack, msgspec, orjson and ujson preconf converters.
(#598) - Preconf converters now handle dictionaries with literal keys properly.
(#599) - Structuring TypedDicts from invalid inputs now properly raises a
ClassValidationError
.
(#615 #616) cattrs.strategies.include_subclasses
now properly works with generic parent classes.
(#649)- Replace
cattrs.gen.MappingStructureFn
withcattrs.SimpleStructureHook
. - Python 3.13 is now supported.
(#543 #547) - Python 3.8 is no longer supported, as it is end-of-life. Use previous versions on this Python version.
(#591) - Change type of
Converter.__init__.unstruct_collection_overrides
fromCallable
toMapping[type, UnstructureHook]
(#594). - Adopt the Contributor Covenant Code of Conduct (just like attrs).