Models for Pythonistas
Project description
# datamodels
The datamodels package builds on dataclasses and adds the following functionality:
.dict() instance method – returns a dict of the data, making it simple to serialize to formats like JSON or YAML.
.from_data() class method – create a new instance by passing in an iterable key-value data source (such as a dict). Unlike the regular constructor, this only uses the values in the input data that match fields in the model — others are ignored. This is useful for pulling model data out of a larger data source.
@validator decorator to specify data validation methods.
.validate() class method – runs the attribute validator methods and returns a dict with the fields that have errors as keys and a list of errors as the values.
The datamodels package is inspired by prior art: Django models and forms, the attrs package by which dataclasses was inspired, and the XML world, where schemas and data validation form a key part of production workflows.
Installation:
`bash pip install datamodels `
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datamodels-0.8.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5cc4b2a734d17f33008f70058abaf55b53ca06104a7e04da45dc62288c3d863 |
|
MD5 | c86b9ae2dcc115a9014f339382016629 |
|
BLAKE2b-256 | f672f50d63badffb6f7affdf2686badff2d31f2981d4717991ac905039d7a567 |