Releases: jcrist/msgspec
Version 0.15.1
Version 0.15.0
- Add support for Generic
Struct
types (#386, #393). - Add support for Generic
dataclasses
andattrs
types (#396). - Add support for Generic
typing.TypedDict
andtyping.NamedTuple
types (#398). - BREAKING: No longer normalize timezones to UTC when decoding
datetime
objects from JSON (#391). - Support decoding unhyphenated UUIDs (#392).
- A few type annotation fixups (#383, #387).
- Dedent docstrings for descriptions when generating JSON schemas (#397).
- Use a variant of
__qualname__
when auto-generating Struct tags rather than__name__
(#399). - Fix bug when handling
typing.Literal
types containing a literalNone
(#400). - Make all
Encoder
/Decoder
methods threadsafe (#402). - BREAKING: Drop the
write_buffer_size
kwarg toEncoder
(#402).
Version 0.14.2
- Remove
__del__
trashcan usage for structs withgc=False
(#369). - Support overriding
__setattr__
in Struct types (#376). - Support encoding large integers in JSON (#378).
- Fix a memory leak when msgpack decoding variable length tuples with more than 16 elements (#380).
- Remove JSON compatibility checks when constructing a
msgspec.json.Decoder
. Trying to decode messages into types that JSON doesn't support will now error at decode time, rather than when the decoder is constructed (#381).
Version 0.14.1
Version 0.14.0
- Support encoding and decoding attrs types (#323).
- Add
repr_omit_defaults
configuration option for omitting struct default values in therepr
(#322). - Expose a struct's configuration through a
__struct_config__
attribute (#328). - Add
msgspec.structs.fields
utility function for inspecting the fields configured on a Struct (#330). - Add a
dict
configuration option for adding a__dict__
attribute to a Struct (#331). - Allow non-struct mixins to be used with struct types (#332).
- Fix a bug when defining both
lt
andgt
constraints on an integer type (#335). - Fix a bug supporting fields defined with
msgspec.field()
with no arguments (#343). - Allow arbitrary input types to
msgspec.from_builtins
(#346). - Support decoding into subclasses of
int
&bytes
inmsgspec.from_builtins
(#346). - Add
msgspec.UNSET
andmsgspec.UnsetType
for tracking unset fields. See the docs for more information (#350). - BREAKING: In the unlikely event you were using the previous
msgspec.UNSET
singleton to explicitly indicate no default value on struct types, you should now make use ofmsgspec.NODEFAULT
instead (#350). - Improve struct type annotations now that
mypy
supportstyping.dataclass_transform
(#352). - Support
typing.Final
annotations for indicating that an object field should be treated as immutable (#354). - Add a
name
keyword option tomsgspec.field
for renaming a single field (#356). - BREAKING: The rules around class inheritance and a struct's
rename
option have changed. See #356 for more information.
Version 0.13.1
- Fix a memory leak in the JSON decoder introduced in 0.13.0, caused by a reference counting bug when decoding into
Struct
types (#312).
Version 0.13.0
- Add
to_builtins
function for converting messages composed of any supported type to ones composed of only simple builtin types commonly supported by Python serialization libraries (#258). - Add
from_builtins
function for converting and validating messages composed of simple builtin types to ones composed of any type msgspec supports (#266, #302). - Add
msgspec.yaml
module for encoding/decoding YAML (#267). - Add
msgspec.toml
module for encoding/decoding TOML (#268). - Add
msgspec.structs.replace
function for creating a copy of an existingStruct
with some changes applied (#262). - Add
msgspec.structs.asdict
andmsgspec.structs.astuple
functions for converting a struct instance to adict
ortuple
respectively (#300). - Support arbitrarily nested
typing.NewType
/typing.Annotated
types (#272). - Improve error message for invalid keyword arguments passed to
Struct.__init__
(#273). - Support
default_factory
configuration forStruct
fields (#274). - BREAKING: With the exception of empty builtin collections (
[]
,{}
,set()
,bytearray()
), mutable default values in Struct types are no longer deepcopied when used. If a different mutable default value is needed, please configure adefault_factory
instead (#274). - Improve performance of creating Structs with default parameters (#274).
- Support
typing.ClassVar
annotations ofStruct
types (#281). - Support encoding/decoding
decimal.Decimal
types (#288). - Support "abstract" type annotations like
collections.abc.MutableMapping
/typing.MutableMapping
in decoders (#290). - Support any string-like or int-like type as a
dict
key when encoding or decoding JSON (#292). - Improved performance encoding large collections in JSON and MessagePack encoders (#294, #298).
Version 0.12.0
-
Support encoding
set
andfrozenset
subclasses (#249). -
Support encoding/decoding
typing.NewType
types (#251). -
Allow creating a
msgspec.Raw
object from astr
(#252). -
Add new experimental
msgspec.inspect
module for inspecting type annotations. This is intended to be used for building downstream tooling based on msgspec-compatible types. See the docs for more information (#253). -
Add new
extra
field tomsgspec.Meta
, for storing arbitrary user-defined metadata (#255). -
Improved performance for JSON encoding strings (#256).
Version 0.11.0
-
Improve performance of constructors for
Struct
types when using keyword arguments (#237). -
Support constraints on dict keys for JSON (#239).
-
Add support for keyword-only arguments in
Struct
types, matching the behavior ofkw_only
fordataclasses
(#242). -
BREAKING: Change the parameter ordering rules used by
Struct
types to match the behavior ofdataclasses
. For most users this change shouldn't break anything. However, if your struct definitions have required fields after optional fields, you'll now get an error on import. This error can be fixed by either:- Reordering your fields so all required fields are before all optional fields
- Using keyword-only parameters (by passing the
kw_only=True
option).
See Field Ordering for more information (#242).
-
Support encoding/decoding dictionaries with integer keys for JSON (#243).
Version 0.10.1
- Ignore attributes with leading underscores (
"_"
) when encodingdataclasses
(#234)