pypi cattrs 26.2.0
v26.2.0

2 hours ago

What's Changed

  • Fix the msgpack and cbor2 converters unstructuring naive datetimes as local time, which made the serialized value depend on the timezone of the machine doing the unstructuring; naive datetimes are now assumed to be UTC, matching what the structure hooks already read back. (#774 #775)
  • Fix override(rename=...) targets containing a quote (or other characters not safe in a bare string literal) crashing code generation with SyntaxError; the rename key is now embedded with repr. (#771)
  • Fix Counter keys not being unstructured with the key type's own hook; the single-type-arg branch passed the whole type-args tuple to the key hook lookup instead of the key type. (#768)
  • Fix create_default_dis_func (aka create_uniq_field_dis_func) failing to disambiguate valid unions depending on the order of the member classes; unique fields are now resolved iteratively to a fixpoint. (#230 #765)
  • Support more recursive types on 3.14+ with specialized factories for annotationlib.ForwardRef. (#740 #741)
  • Converter now uses specialized hook factories to generate hooks for tuples, increasing speed. (#737)
  • Fix an AttributeError in cattrs internals that could be triggered by using the include_subclasses strategy in a structure_hook_factory (#721, #722)
  • Fix TypedDict codegen when keys contain single quotes. (#769)
  • Add CattrsError exception type: all exceptions raised by cattrs inherit from this.
    Literal and date-time validation raise this directly, instead of Exception. (#728)
  • Fix the detailed_validation parameter being passed under the wrong name in namedtuple_dict_structure_factory, causing it to be silently ignored. (#723)
  • cattrs is now autoformatted using Ruff. (#732)
  • Support running the test suite without cbor2 installed. (#748)
  • The union passthrough strategy now supports PEP 695 type aliases as union members. (#753)
  • BaseConverter.register_structure_hook_factory and BaseConverter.register_unstructure_hook_factory now properly return the factory when used as decorators. (#724)
  • The msgspec preconf converter now properly handles recursive classes on Python 3.14+. (#757)

New Contributors

Full Changelog: v26.1.0...v26.2.0

Don't miss a new cattrs release

NewReleases is sending notifications on new releases.