Skip to main content

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.

Source Distribution

dataclass_structor-0.0.6.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

dataclass_structor-0.0.6-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file dataclass_structor-0.0.6.tar.gz.

File metadata

  • Download URL: dataclass_structor-0.0.6.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.19.1

File hashes

Hashes for dataclass_structor-0.0.6.tar.gz
Algorithm Hash digest
SHA256 5c437bc3d521c579d818c3158dbc54b21c5401a63c5e331485f6a0f80ed014b2
MD5 672df9db83ab15013983ef4e7f121595
BLAKE2b-256 4d4c5629b382eafc4c09b7fdfc9b71c0d534fa07d2daaaa350752681ec6dbcc9

See more details on using hashes here.

File details

Details for the file dataclass_structor-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for dataclass_structor-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 930690d452b9cb643dc73dc11e6b506349540fe8709f0e47ebfc06648378a9fa
MD5 28e4de688c249493453a0474f26ce7bd
BLAKE2b-256 f5f0841e57be3babfa3f8dff268ec6773bab0048f79670a170f841f4b101f817

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page