Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Typed object structure/destructure.

Project description

dataclass_structor

Documentation Status PyPI - License PyPI - Python Version PyPI - License Build Status

A type aware structor/destructor for python value objects.

Install

pip install dataclass_structor

Documentation

The docs for this project can be found here.

Example

import dataclasses
import typing

from dataclass_structor import structure, unstructure


@dataclasses.dataclass
class Invite:
    email: str
    guests: typing.List["Guest"]


@dataclasses.dataclass
class Guest:
    first_name: typing.Optional[str] = None


value_type = Invite(
    email="testing",
    guests=[
      Guest(first_name="John"),
      Guest(),
    ],
)

x = unstructure(value_type)
assert x == {"email": "", "guests": [{"first_name": "John"}, {"first_name": None}]}

assert structure(x, Invite) == value_type

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dataclass_structor, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size dataclass_structor-0.0.6-py3-none-any.whl (11.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dataclass_structor-0.0.6.tar.gz (29.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page