jcrist · GitHub

added 6 commits

March 22, 2023 21:43
This makes the internal `NODEFAULT` singleton public, and switches the
all previous usage of `msgspec.UNSET` to use `msgspec.NODEFAULT`
instead.
This is a *breaking change*. In the unlikely case a user was using
`msgspec.UNSET` directly (it's a fairly fringe API to use), they should
move to using `msgspec.NODEFAULT` instead. This breaking change is
needed so we can reclaim the `msgspec.UNSET` singleton for an
alternate purpose.
This adds support for encoding object-like types (Struct, dataclasses,
attrs) where some fields may contain the `msgspec.UNSET` singleton. In
this case, these fields are omitted from the encoded message.
Encoding `msgspec.UNSET` in locations other than a direct object field
(e.g. in `[1, 2, msgspec.UNSET]`) will result in a type error.
This makes UNSET's semantics the same as `None`, except it's a different
singleton.

Closed

SyntaxColoring

This lets type checkers do a better job of type narrowing. For ease of
implementation we only make this change in the type stubs. In normal
usage the singleton object and types should be treated as opaque objects
by users, lieing in the type stubs here seems unlikely to cause an
issue.

@jcrist

@jcrist

Closed

13 tasks

Closed

Read the original on github.com ↗