-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cover omit_defaults
handling in asdict
and to_builtins
documentation
#778
Comments
asdict
should respect omit_defaults
asdict
that respects omit_defaults
asdict
that respects omit_defaults
omit_defaults
handling in asdict
and to_builtins
documentation
After exploring the docs further, I discovered that the "recursively convert to builtin types, while respecting Neither The other thing that tripped me up was that https://jcristharif.com/msgspec/usage.html doesn't cover the non-serialisation case, so the fact that I'll create a PR with some suggested docs tweaks. |
Also clarify differences between `to_builtins` and `asdict`. Closes jcrist#778
#780 attempts to cover the points above in both the main usage docs, as well as in the docstrings of |
Description
(I'm not sure if this is a bug report or a feature request, so I opted for a feature request in case the current behaviour is intentional)
I am using
msgspec
to help communicate with a server where a boolean field can be set toNone
in the data model not becausenull
is a valid value, but because it is permitted to omit the key entirely. The relevant struct hasomit_defaults=True
set accordingly.However,
msgspec
isn't handling the full message serialisation (httpx
is doing that), so I attempted to useasdict
to generate the message spec portion of the message.This failed, as
asdict
includes all fields, without paying attention toomit_defaults
.The text was updated successfully, but these errors were encountered: