Desert: DRY deserialization
| docs | |
|---|---|
| code | |
| tests | |
| package |
Desert generates serialization schemas for dataclasses and attrs classes. Writing
code that's DRY ("don't repeat yourself") helps avoid bugs and improve readability. Desert
helps you write code that's DRY.
Installation
pip install desert
or with Poetry
poetry add desert
Usage
A simple example models two Person objects in a Car.
from dataclasses import dataclass
# Or using attrs
# from attr import dataclass
from typing import List
import desert
@dataclass
class Person:
name: str
age: int
@dataclass
class Car:
passengers: List[Person]
# Load some simple data types.
data = {'passengers': [{'name': 'Alice', 'age': 21}, {'name': 'Bob', 'age': 22}]}
# Create a schema for the Car class.
schema = desert.schema(Car)
# Load the data.
car = schema.load(data)
assert car == Car(passengers=[Person(name='Alice', age=21), Person(name='Bob', age=22)])Documentation
https://desert.readthedocs.io/
Limitations
String annotations and forward references inside of functions are not supported.
Acknowledgements
- This package began as an extension of marshmallow-dataclass to add support for attrs.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
