# What changed in msgspec

> 36 changes in msgspec 0.21 to 0.22 from its official release notes, upgrade guides and advisories: 5 breaking, 5 new APIs and options. Each one cited. Sources checked 2026-10-29. HTML: https://unstale.sh/pypi/msgspec/

To see which of these apply to a repository, run `npx @unstale/cli init` in it.

## msgspec 0.22

### Breaking changes

- Out-of-range integers converted to a float target now raise ValidationError instead of SystemError. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- JSON schema defaults for Struct fields with set or bytearray default factories use [] or "" rather than Python set or bytearray objects. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Meta type stubs add overloads so type checkers reject mixing gt with ge or lt with le. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Setting gc=False on a struct type with a weakref slot now raises ValueError, consistently on all supported Python versions. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)

### New APIs and options

- Encoder accepts a callable as decimal_format for custom Decimal encoding in JSON and MessagePack. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- frozendict is supported on Python 3.15 and later. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Literal[True] and Literal[False] are now supported types. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- The PyEmscripten (Pyodide) platform is now supported. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)

### Tooling

- Linux riscv64 wheels are now published. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Type stubs receive multiple improvements and fixes. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)

### Fixes and other changes

- JSON schema minItems is corrected for array_like structs whose fields are all optional. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- When a non-Raw value is given for a Raw field, the expected type is reported as raw rather than any. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Wheels are published for CPython 3.15, including freethreaded builds. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- 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.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- 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.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- The backing type declaration of Ext.code is fixed. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Error messages for out-of-range Meta length bounds are corrected. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- type_info no longer crashes on mixed-type Literals such as Literal[1, None]. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Encoding a dict keyed by a plain enum.Enum with str values no longer raises TypeError. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- JSON schema generation no longer crashes on mixed-type Literals such as Literal[1, None]. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Generated JSON schemas place null last in the anyOf for optional unions. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Handling of PEP 695 type parameter syntax, such as class Foo[T], is fixed. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- JSON Schema metadata and string constraints are preserved in propertyNames for annotated dictionary key types. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Creating a Struct with an unquoted forward reference no longer raises NameError on Python 3.14. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Handling of types.GenericAlias instances in type annotations is fixed. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- Incorrect typing.ClassVar annotations no longer cause a crash. (0.22.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)
- 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.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.22.0)

## msgspec 0.21

### Breaking changes

- Calls __post_init__ from msgspec.structs.replace and copy.replace. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)

### New APIs and options

- Adds the ref_template argument to msgspec.json.schema. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)

### Tooling

- Improves type annotations for msgspec.UNSET. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)

### Fixes and other changes

- ValidationError and DecodeError raised in dec_hook are no longer incorrectly wrapped in another ValidationError. (0.21.1) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.1)
- The type stub now includes the ref_template parameter, so the declared signature matches the API. (0.21.1) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.1)
- Fixes a segfault on Python 3.13+ when creating structs that contain a __dict__. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)
- Fixes a memory leak when decoding sets. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)
- JSON schemas for set and frozenset now include a uniqueItems annotation. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)
- Fixes hashing of decoded tuples on Python 3.14. (0.21.0) — [release notes](https://github.com/msgspec/msgspec/releases/tag/0.21.0)
