Skip to main content

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


Download files

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

Source Distribution

datamodels-0.4.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datamodels-0.4.0-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file datamodels-0.4.0.tar.gz.

File metadata

  • Download URL: datamodels-0.4.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for datamodels-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0c9ee4a0926a139509af6f7d10ec34ea861d1592b762514f7213ab43772c755b
MD5 db1f56bd7d473e4f91ece7b8177d83c1
BLAKE2b-256 d35e3e03f7f0b5ab5e256d7d24273d3d1b1d6d593dc4660076406e51cbe6ff22

See more details on using hashes here.

File details

Details for the file datamodels-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: datamodels-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for datamodels-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 321247a655817436cc527c4298bf96d5a7fcd1f8b9d5824a08b33add285d898d
MD5 77a34b23533b35c6ddbadb3f7e1cd4b0
BLAKE2b-256 b2af3f9e15fa87fd6beb47863feff98c64f11690ba52618f84266f346d9749c3

See more details on using hashes here.

Supported by

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