Typed object structure/destructure.
Project description
dataclass_structor
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 hashes)
Built Distribution
Close
Hashes for dataclass_structor-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 930690d452b9cb643dc73dc11e6b506349540fe8709f0e47ebfc06648378a9fa |
|
MD5 | 28e4de688c249493453a0474f26ce7bd |
|
BLAKE2b-256 | f5f0841e57be3babfa3f8dff268ec6773bab0048f79670a170f841f4b101f817 |