unstale

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 init

@unstale/cli 0.2.9 on npm

msgspec 0.2227 changes

Breaking changes 4

  • Out-of-range integers converted to a float target now raise ValidationError instead of SystemError.

    0.22.0release notes

  • JSON schema defaults for Struct fields with set or bytearray default factories use [] or "" rather than Python set or bytearray objects.

    0.22.0release notes

  • Meta type stubs add overloads so type checkers reject mixing gt with ge or lt with le.

    0.22.0release notes

  • Setting gc=False on a struct type with a weakref slot now raises ValueError, consistently on all supported Python versions.

    0.22.0release notes

New APIs and options 4

  • Encoder accepts a callable as decimal_format for custom Decimal encoding in JSON and MessagePack.

    0.22.0release notes

  • frozendict is supported on Python 3.15 and later.

    0.22.0release notes

  • Literal[True] and Literal[False] are now supported types.

    0.22.0release notes

  • The PyEmscripten (Pyodide) platform is now supported.

    0.22.0release notes

Tooling 2

Fixes and other changes 17

  • JSON schema minItems is corrected for array_like structs whose fields are all optional.

    0.22.0release notes

  • When a non-Raw value is given for a Raw field, the expected type is reported as raw rather than any.

    0.22.0release notes

  • Wheels are published for CPython 3.15, including freethreaded builds.

    0.22.0release notes

  • inspect.signature and rendered docs now report the leading argument of encode and decode functions and methods as positional-only, matching runtime behavior.

    0.22.0release notes

  • inspect.signature and rendered docs now report the leading argument of encode and decode functions and methods as positional-only, matching runtime behavior.

    0.22.0release notes

  • The backing type declaration of Ext.code is fixed.

    0.22.0release notes

  • Error messages for out-of-range Meta length bounds are corrected.

    0.22.0release notes

  • type_info no longer crashes on mixed-type Literals such as Literal[1, None].

    0.22.0release notes

  • Encoding a dict keyed by a plain enum.Enum with str values no longer raises TypeError.

    0.22.0release notes

  • JSON schema generation no longer crashes on mixed-type Literals such as Literal[1, None].

    0.22.0release notes

  • Generated JSON schemas place null last in the anyOf for optional unions.

    0.22.0release notes

  • Handling of PEP 695 type parameter syntax, such as class Foo[T], is fixed.

    0.22.0release notes

  • JSON Schema metadata and string constraints are preserved in propertyNames for annotated dictionary key types.

    0.22.0release notes

  • Creating a Struct with an unquoted forward reference no longer raises NameError on Python 3.14.

    0.22.0release notes

  • Handling of types.GenericAlias instances in type annotations is fixed.

    0.22.0release notes

  • Incorrect typing.ClassVar annotations no longer cause a crash.

    0.22.0release notes

  • 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.

    0.22.0release notes

msgspec 0.219 changes

Breaking changes 1

  • Calls __post_init__ from msgspec.structs.replace and copy.replace.

    0.21.0release notes

New APIs and options 1

  • Adds the ref_template argument to msgspec.json.schema.

    0.21.0release notes

Tooling 1

Fixes and other changes 6

  • ValidationError and DecodeError raised in dec_hook are no longer incorrectly wrapped in another ValidationError.

    0.21.1release notes

  • The type stub now includes the ref_template parameter, so the declared signature matches the API.

    0.21.1release notes

  • Fixes a segfault on Python 3.13+ when creating structs that contain a __dict__.

    0.21.0release notes

  • Fixes a memory leak when decoding sets.

    0.21.0release notes

  • JSON schemas for set and frozenset now include a uniqueItems annotation.

    0.21.0release notes

  • Fixes hashing of decoded tuples on Python 3.14.

    0.21.0release notes