marsh.schema.template
¶
A set of template implementations of schemas.
These templates are useful as base classes when extending the framework to support more types.
- class CallableUnmarshalSchema(*args, **kwargs)[source]¶
Unmarshals the arguments to a callable and uses them to call it.
- Parameters:
value (Type[_T]) –
- schemas: Mapping[str, UnmarshalSchema]¶
The schemas for the fixed attributes.
- class MappingUnmarshalSchema(*args, default='???', default_factory='???', **kwargs)[source]¶
A schema for a type with dynamic keys and values.
- Parameters:
value (Type[_T]) –
- key_schema: UnmarshalSchema¶
The schema for the key type.
- value_schema: UnmarshalSchema¶
The schema for the value type.
- class SequenceUnmarshalSchema(*args, default='???', default_factory='???', **kwargs)[source]¶
A schema for a dynamic sequence of values.
- Parameters:
value (Type[_T]) –
- value_schema: UnmarshalSchema¶
The schema for the value type.
- class StructuredUnmarshalSchema(*args, default='???', default_factory='???', **kwargs)[source]¶
A schema for types with fixed attributes that are recursively unmarshaled.
Supports both positional arguments and keyword arguments. Variable versions of these arguments (typically
*args
/**kwargs
) are also supported and are marked by*
or**
infront of their names in theschemas
attribute of this class.- Parameters:
value (Type[_T]) –
- schemas: Mapping[str, UnmarshalSchema]¶
The schemas for the fixed attributes.
- class UnionUnmarshalSchema(*args, default='???', default_factory='???', **kwargs)[source]¶
A schema for a union of types.
The order of the types is reflected in the order of attempted unmarshals. The value of the first type that is successfully unmarshaled is returned.
If all types failed to unmarshal an error is raised.
- Parameters:
value (Type[_T]) –
- schemas: Sequence[UnmarshalSchema]¶
The schemas for the union of types.