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
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.5.tar.gz
(29.5 kB
view hashes)
Built Distribution
Close
Hashes for dataclass_structor-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272437d9e21e882db2d7127665416c1f35d933771097d0729088950a5013b0c8 |
|
MD5 | 92fd7863fdf64159c495cd39b09c8df2 |
|
BLAKE2b-256 | 7b80665b2f8928b38b76c2fec6a67036259a1f03866ddc3fe24d6a646094dbe7 |