GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - python-desert/desert: Deserialize to objects while staying DRY

BranchesTags
Open more actions menu

Latest commit

 

History

543 Commits
543 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
changelog.d
changelog.d
 
 
ci
ci
 
 
docs
docs
 
 
src/desert
src/desert
 
 
tests
tests
 
 
.bumpversion.cfg
.bumpversion.cfg
 
 
.cookiecutterrc
.cookiecutterrc
 
 
.coveragerc
.coveragerc
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.pylintrc
.pylintrc
 
 
.readthedocs.yml
.readthedocs.yml
 
 
AUTHORS.rst
AUTHORS.rst
 
 
CHANGELOG.rst
CHANGELOG.rst
 
 
CONTRIBUTING.rst
CONTRIBUTING.rst
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
README.rst
README.rst
 
 
dev-requirements.in
dev-requirements.in
 
 
dev-requirements.txt
dev-requirements.txt
 
 
mypy.ini
mypy.ini
 
 
pycli
pycli
 
 
pyproject.toml
pyproject.toml
 
 
requirements.in
requirements.in
 
 
requirements.txt
requirements.txt
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 
test-requirements.in
test-requirements.in
 
 
test-requirements.txt
test-requirements.txt
 
 
tox.ini
tox.ini
 
 

Repository files navigation

Desert: DRY deserialization

docs Documentation Status
code
Latest commit
tests
GitHub Actions Build Status
Coverage Status
package
PyPI Package latest release
PyPI Wheel
Supported versions
Supported implementations

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.

About

Deserialize to objects while staying DRY

desert.readthedocs.io

Topics

attrsdataclassesmarshmallowpythonserialization

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

161 stars

Watchers

3 watching

Forks

11 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.