cattrs.preconf package¶
- cattrs.preconf.wrap(_)[source]¶
Wrap a Converter __init__ in a type-safe way.
- Parameters:
_ (Callable[[~P], Any])
- Return type:
Callable[[Callable[[…], T]], Callable[[~P], T]]
- cattrs.preconf.is_primitive_enum(type, include_bare_enums=False)[source]¶
Is this a string or int enum that can be passed through?
- Parameters:
type (Any)
include_bare_enums (bool)
- Return type:
bool
- cattrs.preconf.literals_with_enums_unstructure_factory(typ, converter)[source]¶
An unstructure hook factory for literals containing enums.
If all contained enums can be passed through (their unstructure hook is identity), the entire literal can also be passed through.
- Parameters:
typ (Any)
converter (Converter)
- Return type:
Callable[[Any], Any]
Submodules¶
cattrs.preconf.bson module¶
Preconfigured converters for bson.
- class cattrs.preconf.bson.Base85Bytes[source]¶
Bases:
bytesA subclass to help with binary key encoding/decoding.
- class cattrs.preconf.bson.BsonConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, check_keys=False, codec_options=(<class 'dict'>, False, 0, 'strict', None, TypeRegistry(type_codecs=[], fallback_encoder=None), DatetimeConversion.DATETIME))[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
check_keys (bool)
codec_options (CodecOptions)
- Return type:
bytes
- loads(data, cl, codec_options=(<class 'dict'>, False, 0, 'strict', None, TypeRegistry(type_codecs=[], fallback_encoder=None), DatetimeConversion.DATETIME))[source]¶
- Parameters:
data (bytes)
cl (type[T])
codec_options (CodecOptions)
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.bson.configure_converter(converter)[source]¶
Configure the converter for use with the bson library.
sets are serialized as lists
byte mapping keys are base85-encoded into strings when unstructuring, and reverse
non-string, non-byte mapping keys are coerced into strings when unstructuring
a deserialization hook is registered for bson.ObjectId by default
string and int enums are passed through when unstructuring
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (BaseConverter)
cattrs.preconf.cbor2 module¶
Preconfigured converters for cbor2.
- class cattrs.preconf.cbor2.Cbor2Converter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
bytes
- loads(data, cl, **kwargs)[source]¶
- Parameters:
data (bytes)
cl (type[T])
kwargs (Any)
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.cbor2.configure_converter(converter)[source]¶
Configure the converter for use with the cbor2 library.
datetimes are serialized as timestamp floats
sets are serialized as lists
string and int enums are passed through when unstructuring
- Parameters:
converter (BaseConverter)
cattrs.preconf.json module¶
Preconfigured converters for the stdlib json.
- class cattrs.preconf.json.JsonConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
str
- loads(data, cl, **kwargs)[source]¶
- Parameters:
data (bytes | str)
cl (type[T])
kwargs (Any)
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.json.configure_converter(converter)[source]¶
Configure the converter for use with the stdlib json module.
bytes are serialized as base85 strings
datetimes are serialized as ISO 8601
counters are serialized as dicts
sets are serialized as lists
string and int enums are passed through when unstructuring
union passthrough is configured for unions of strings, bools, ints, floats and None
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (BaseConverter)
- Return type:
None
cattrs.preconf.msgpack module¶
Preconfigured converters for msgpack.
- class cattrs.preconf.msgpack.MsgpackConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
bytes
- loads(data, cl, **kwargs)[source]¶
- Parameters:
data (bytes)
cl (type[T])
kwargs (Any)
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.msgpack.configure_converter(converter)[source]¶
Configure the converter for use with the msgpack library.
datetimes are serialized as timestamp floats
sets are serialized as lists
string and int enums are passed through when unstructuring
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (BaseConverter)
- Return type:
None
cattrs.preconf.msgspec module¶
Preconfigured converters for msgspec.
- class cattrs.preconf.msgspec.MsgspecJsonConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
ConverterA converter specialized for the _msgspec_ library.
- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- encoder: Encoder = <msgspec.json.Encoder object>¶
The msgspec encoder for dumping.
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
Unstructure and encode obj into JSON bytes.
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
bytes
- get_dumps_hook(unstructure_as, **kwargs)[source]¶
Produce a dumps hook for the given type.
- Parameters:
unstructure_as (Any)
kwargs (Any)
- Return type:
Callable[[Any], bytes]
- loads(data, cl, **kwargs)[source]¶
Decode and structure cl from the provided JSON bytes.
- Parameters:
data (bytes)
cl (type[T])
kwargs (Any)
- Return type:
T
- get_loads_hook(cl)[source]¶
Produce a loads hook for the given type.
- Parameters:
cl (type[T])
- Return type:
Callable[[bytes], T]
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.msgspec.configure_converter(converter)[source]¶
Configure the converter for the msgspec library.
bytes are serialized as base64 strings, directly by msgspec
datetimes and dates are passed through to be serialized as RFC 3339 directly
enums are passed through to msgspec directly
union passthrough configured for str, bool, int, float and None
bare, string and int enums are passed through when unstructuring
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (Converter)
- Return type:
None
cattrs.preconf.orjson module¶
Preconfigured converters for orjson.
- class cattrs.preconf.orjson.OrjsonConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
bytes
- loads(data, cl)[source]¶
- Parameters:
data (bytes | bytearray | memoryview | str)
cl (type[T])
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.orjson.configure_converter(converter)[source]¶
Configure the converter for use with the orjson library.
bytes are serialized as base85 strings
datetimes and dates are passed through to be serialized as RFC 3339 by orjson
typed namedtuples are serialized as lists
sets are serialized as lists
string enum mapping keys have special handling
mapping keys are coerced into strings when unstructuring
bare, string and int enums are passed through when unstructuring
Changed in version 24.1.0: Add support for typed namedtuples.
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (Converter)
- Return type:
None
cattrs.preconf.pyyaml module¶
Preconfigured converters for pyyaml.
- class cattrs.preconf.pyyaml.PyyamlConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
str
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.pyyaml.configure_converter(converter)[source]¶
Configure the converter for use with the pyyaml library.
frozensets are serialized as lists
string enums are converted into strings explicitly
datetimes and dates are validated
typed namedtuples are serialized as lists
Changed in version 24.1.0: Add support for typed namedtuples.
- Parameters:
converter (BaseConverter)
- Return type:
None
cattrs.preconf.tomlkit module¶
Preconfigured converters for tomlkit.
- class cattrs.preconf.tomlkit.TomlkitConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
str
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.tomlkit.configure_converter(converter)[source]¶
Configure the converter for use with the tomlkit library.
bytes are serialized as base85 strings
sets are serialized as lists
tuples are serializas as lists
mapping keys are coerced into strings when unstructuring
Changed in version 26.1.0: date objects are now passed through to tomlkit without unstructuring.
- Parameters:
converter (BaseConverter)
cattrs.preconf.tomllib module¶
Preconfigured converters for tomllib.
- class cattrs.preconf.tomllib.TomllibConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
ConverterA converter subclass specialized for tomllib.
- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
str
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.tomllib.configure_converter(converter)[source]¶
Configure the converter for use with the tomllib library.
bytes are serialized as base85 strings
sets are serialized as lists
tuples are serializas as lists
mapping keys are coerced into strings when unstructuring
dates and datetimes are left for tomllib to handle
- Parameters:
converter (BaseConverter)
cattrs.preconf.ujson module¶
Preconfigured converters for ujson.
- class cattrs.preconf.ujson.UjsonConverter(dict_factory=<class 'dict'>, unstruct_strat=UnstructureStrategy.AS_DICT, omit_if_default=False, forbid_extra_keys=False, type_overrides={}, unstruct_collection_overrides={}, prefer_attrib_converters=False, detailed_validation=True, unstructure_fallback_factory=<function Converter.<lambda>>, structure_fallback_factory=<function Converter.<lambda>>, use_alias=False)[source]¶
Bases:
Converter- Parameters:
detailed_validation (bool) – Whether to use a slightly slower mode for detailed validation errors.
unstructure_fallback_factory (HookFactory[UnstructureHook]) – A hook factory to be called when no registered unstructuring hooks match.
structure_fallback_factory (HookFactory[StructureHook]) – A hook factory to be called when no registered structuring hooks match.
use_alias (bool) – Whether to use the field alias instead of the field name as the un/structured dictionary key by default.
dict_factory (Callable[[], Any])
unstruct_strat (UnstructureStrategy)
omit_if_default (bool)
forbid_extra_keys (bool)
type_overrides (Mapping[type, AttributeOverride])
unstruct_collection_overrides (Mapping[type, UnstructureHook])
prefer_attrib_converters (bool)
Added in version 23.2.0: unstructure_fallback_factory
Added in version 23.2.0: structure_fallback_factory
Changed in version 24.2.0: The default structure_fallback_factory now raises errors for missing handlers more eagerly, surfacing problems earlier.
Added in version 25.2.0: use_alias
- dumps(obj, unstructure_as=None, **kwargs)[source]¶
- Parameters:
obj (Any)
unstructure_as (Any)
kwargs (Any)
- Return type:
str
- loads(data, cl, **kwargs)[source]¶
- Parameters:
data (AnyStr)
cl (type[T])
kwargs (Any)
- Return type:
T
- forbid_extra_keys¶
- omit_if_default¶
- type_overrides¶
- use_alias¶
- cattrs.preconf.ujson.configure_converter(converter)[source]¶
Configure the converter for use with the ujson library.
bytes are serialized as base64 strings
datetimes are serialized as ISO 8601
sets are serialized as lists
string and int enums are passed through when unstructuring
Changed in version 24.2.0: Enums are left to the library to unstructure, speeding them up.
- Parameters:
converter (BaseConverter)