msgspec.from_builtins
-> msgspec.convert
#431
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a major overhaul of the existing
msgspec.from_builtins
function.In short: the capabilities of
msgspec.from_builtins
have been expanded to support a wider range of input types (the full set of types supported by othermsgspec
functions). To better match the new capabilities,msgspec.from_builtins
function has been renamed tomsgspec.convert
, with the old name deprecated.Summary:
msgspec.from_builtins
has been deprecated and renamed tomsgspec.convert
. The capabilities ofconvert
are a superset of those of the oldfrom_builtins
. Note that some of the keyword arguments have changed names.from_builtins
available by settingstr_values=True
is now renamed tostrict=False
inmsgspec.convert
. Settingstrict=False
enables a laxer set of coercion rules (msgspec is strict by default). The intent is to support this kwarg in all decoders in a follow-up PR.attributes
kwarg added in Addattributes
option tofrom_builtins
#419 has been renamed tofrom_attributes
. Since this feature hasn't been released yet, this is not a breaking change.msgspec.convert
now supports any supported type as input. For the most part non-python-builtin types (e.g. dataclasses, attrs, ...) won't coerce to any other types, but will be type checked.Note that the prose documentation hasn't been updated yet, this will done in a follow-up PR before the next release, once the remaining refactor changes have landed.