pypi / msgspec
msgspec
What changed in msgspec 0.21 to 0.22, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-29.
5 breaking5 new APIs and options3 tooling23 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmsgspec 0.2227 changes
Breaking changes 4
Out-of-range integers converted to a float target now raise ValidationError instead of SystemError.
JSON schema defaults for Struct fields with set or bytearray default factories use [] or "" rather than Python set or bytearray objects.
Meta type stubs add overloads so type checkers reject mixing gt with ge or lt with le.
Setting gc=False on a struct type with a weakref slot now raises ValueError, consistently on all supported Python versions.
New APIs and options 4
Encoder accepts a callable as decimal_format for custom Decimal encoding in JSON and MessagePack.
frozendict is supported on Python 3.15 and later.
Literal[True] and Literal[False] are now supported types.
The PyEmscripten (Pyodide) platform is now supported.
Tooling 2
Linux riscv64 wheels are now published.
Type stubs receive multiple improvements and fixes.
Fixes and other changes 17
JSON schema minItems is corrected for array_like structs whose fields are all optional.
When a non-Raw value is given for a Raw field, the expected type is reported as raw rather than any.
Wheels are published for CPython 3.15, including freethreaded builds.
inspect.signature and rendered docs now report the leading argument of encode and decode functions and methods as positional-only, matching runtime behavior.
inspect.signature and rendered docs now report the leading argument of encode and decode functions and methods as positional-only, matching runtime behavior.
The backing type declaration of Ext.code is fixed.
Error messages for out-of-range Meta length bounds are corrected.
type_info no longer crashes on mixed-type Literals such as Literal[1, None].
Encoding a dict keyed by a plain enum.Enum with str values no longer raises TypeError.
JSON schema generation no longer crashes on mixed-type Literals such as Literal[1, None].
Generated JSON schemas place null last in the anyOf for optional unions.
Handling of PEP 695 type parameter syntax, such as class Foo[T], is fixed.
JSON Schema metadata and string constraints are preserved in propertyNames for annotated dictionary key types.
Creating a Struct with an unquoted forward reference no longer raises NameError on Python 3.14.
Handling of types.GenericAlias instances in type annotations is fixed.
Incorrect typing.ClassVar annotations no longer cause a crash.
Validation errors no longer show an empty expected-type name for required Raw TypedDict fields or Raw fields with default_factory on dataclass or attrs classes.
msgspec 0.219 changes
Breaking changes 1
Calls __post_init__ from msgspec.structs.replace and copy.replace.
New APIs and options 1
Adds the ref_template argument to msgspec.json.schema.
Tooling 1
Improves type annotations for msgspec.UNSET.
Fixes and other changes 6
ValidationError and DecodeError raised in dec_hook are no longer incorrectly wrapped in another ValidationError.
The type stub now includes the ref_template parameter, so the declared signature matches the API.
Fixes a segfault on Python 3.13+ when creating structs that contain a __dict__.
Fixes a memory leak when decoding sets.
JSON schemas for set and frozenset now include a uniqueItems annotation.
Fixes hashing of decoded tuples on Python 3.14.