desert package

Submodules

desert.exceptions module

exception desert.exceptions.DesertException[source]

Bases: Exception

Top-level exception for desert.

exception desert.exceptions.NotAnAttrsClassOrDataclass[source]

Bases: desert.exceptions.DesertException

Raised for dataclass operations on non-dataclasses.

exception desert.exceptions.UnknownType[source]

Bases: desert.exceptions.DesertException

Raised for a type with unknown serialization equivalent.

Module contents

desert.field(marshmallow_field, **kw)[source]

Specify a marshmallow field in the metadata for a dataclasses.dataclass.

@dataclasses.dataclass
class A:
    x: int = desert.field(marshmallow.fields.Int())
Return type

Field

desert.ib(marshmallow_field, **kw)[source]

Specify a marshmallow field in the metadata for an attr.dataclass.

@attr.dataclass
class A:
    x: int = desert.ib(marshmallow.fields.Int())
Return type

_CountingAttr

desert.metadata(field)[source]

Specify a marshmallow field in the field metadata.

x: int = attr.ib(metadata=desert.metadata(marshmallow.fields.Int()))
desert.schema(cls, many=False, meta={})[source]

Build a marshmallow schema instance for the class.

Parameters
Return type

Schema

Returns

An instance of the marshmallow schema for the class.

desert.schema_class(cls, meta={})[source]

Build a marshmallow schema class for the class.

Parameters
Return type

Type[Schema]

Returns

The marshmallow schema class.