Version 0.23.0 (2026-11-28)
New features
- Support converting non-dict mappings to
TypedDicttypes withconvert(#1240). - Include JSON Schema defaults for dataclass and
attrsfields with builtinlist,dict,setorbytearraydefault factories (#1222).
Bug fixes
- Fix a reference leak when building a decoder for a
tuplesubclass whose_fieldsattribute is not an exacttuple(#1377). - Return one-dimensional unsigned-byte views for MessagePack binary values decoded as
memoryviewand extension data passed toext_hook, including non-byte and multidimensional input buffers. Preserve shared storage and its lifetime (#1373). - Fix MessagePack list encoding races on free-threaded Python builds (#1252).
- Fix races when types are first used concurrently for decoding or conversion, and avoid reusing incomplete recursive
TypedDictstate after schema construction fails (#1359, #1258). - Treat
attrsfields without annotations asAny, or as theirattr.ib(type=...)type, during decoding, conversion, inspection and JSON Schema generation (#1367). - Propagate unexpected field-access and dictionary-lookup errors during dataclass encoding, object conversion and sorted output (#1271, #1323, #1369).
- Fix module namespace resolution and missing-annotation errors when defining or inspecting
Structtypes (#1271). - Apply inherited generic
TypedDictarguments to subclass fields and resolve PEP 695 type parameters correctly with postponed annotations, without substituting same-named module-levelTypeVarobjects (#1230, #1130). - Preserve
TypedDictrequiredness, constraints and schema metadata whenAnnotatedappears outsideRequiredorNotRequired(#1321). - Raise
DecodeErrorinstead ofUnicodeDecodeErrorfor invalid UTF-8 input decoded as JSON, MessagePack or TOML (#1331, #1270). - Raise
DecodeErrorfor invalid YAML scalar values that previously raisedValueError,LookupErrororAttributeErrorduring parsing (#1337). - Raise
TypeErrorinstead ofAttributeErrorfromtoml.encodewhen the converted top-level value is not a table (#1370). - Avoid shrinking
Encoder.encode_intobuffer capacity at an existing offset, zero-fill gaps before an offset, and remove stale trailing contents after failed encoding (#1310). - Quote
DecimalJSON dictionary keys, including whendecimal_format="number", and reject non-finiteDecimalvalues in number mode (#1216, #1263). - Honor
str_keys=Truefor dictionary keys even when their types appear inbuiltin_types, including date and time keys in TOML (#1217). - Apply
dec_hookwhen converting custom dictionary-key types (#1238). - Raise path-aware
ValidationErrorfor unhashable set items or converted dictionary keys, and reject objects without akeysattribute when converting to a dictionary (#1296, #1309). - Reject embedded NUL bytes in datetime and time strings, and report epoch timestamps or rounding beyond year 9999 as
ValidationError(#1314, #1212). - Reject overflowing day counts when decoding ISO 8601 durations (#1320).
- Correct encoding of UTC offsets within a minute of +/-24 hours, which were previously written as
Z(#1298). - Use a fast path for subnormal JSON float parsing and initialize the portable leading-zero-count fallback (#1237, #1264).
- Preserve outer descriptive
Metavalues whenAnnotatedlayers are separated byNewTypeor type aliases in inspection and JSON Schema. Validation constraints are unchanged (#1371). - Fix JSON Schema descriptions taken from multi-line docstrings keeping the indentation of every line after the first on Python 3.12 and older, when the summary starts on the line with the opening quotes. Tabs in such docstrings are now expanded to spaces on those versions, as they already are on 3.13+ (#1375, #1379).
- Support enums with custom metaclasses in inspection and JSON Schema (#1346).
- Require valid
_fieldsand_field_defaultsmetadata when identifying named tuples, and use the same checks during inspection (#1259, #1313). - Generate distinct JSON Schema component names for types that share a module and qualified name, and support empty component names, including recursive types (#1225, #1274).
- Omit empty
prefixItemsarrays from JSON schemas for fieldless array-like structs and named tuples (#1360). - Preserve string
Literal, enum and union dictionary-key constraints in JSON SchemapropertyNames(#1273, #1355). - Include declared zero and composite
FlagandIntFlagmembers in generated JSON schemas (#1229). - Copy dictionaries returned by
schema_hookbefore adding field defaults, avoiding mutation of the returned top-level dictionary (#1339). - Correct JSON and MessagePack decoder stubs to use
TypeFormfor supported type expressions. With mypy 2.1, enable--enable-incomplete-feature=TypeForm; mypy 2.2 enables it by default (#1245). - Mark read-only attributes as
Finalin type stubs (#1244). - Fix object lifetime handling for
Meta(pattern=...)constraints and report missing fields inStruct.__rich_repr__before comparing defaults (#1256, #1257). - Propagate errors from
ClassVarlookup instead of leaving an exception set duringStructcreation (#1223, #1269). - Fix error handling for oversized
Metanumeric arguments, very large integermultiple_ofconstraints and failed truth-value conversions (#1260, #1265). - Propagate allocation failure when decoding ASCII JSON strings (#1241).
- Correct fixed-size type metadata for
Raw(#1268). - Fix reference leaks in JSON
encode_linesiterators, replaced regex constraints, UUID conversion error paths, Python 3.14 union resolution and MessagePack sorted-encoding error paths (#1284, #1261, #1327, #1248). - Release temporary import references during module initialization, including references to
uuidanddecimal(#1081, #1267). - Fix MessagePack encoding of dictionary keys typed as
frozendicton Python 3.15 (#1283).
Full Changelog: 0.22.0...0.23.0