Marshmallow and Python 3 annotations
Project description
Annotype combines Python 3 annotations and Marshmallow for powerful validation of function arguments.
from annotype import annotyped
from marshmallow import (
Schema,
fields
)
class PersonSchema(Schema):
firstname = fields.Str(required=True)
lastname = fields.Str(required=True)
@annotyped()
def salute(person: SampleSchema):
print 'Hello {} {}'.format(person['firstname'], person['lastnamename'])
person = dict(firstname='John')
# This will raise a ValidationError because lastname is not defined
salute(person)
@annotyped()
def welcome(firstname: fields.Str(), lastname: fields.Str()):
print 'Welcome {} {}'.format(firstname, lastname)
# This will also raise a ValidationError because lastname is not a string
welcome('Jane', 1)
In short, annotype allows you to validate data using the powerful marshmallow library and the Python 3 annotations.
Get It Now
$ pip install -U annotype
Documentation
See marshmallow documentation available here http://marshmallow.readthedocs.io/ .
Requirements
Python >= 3.4
marshmallow >= 3.0.0
License
MIT licensed. See the bundled LICENSE file for more details.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for annotype-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c655b1f0c824fea8480145a0a3d06aa7f11e9b51ea133f7423eed63e0da8f260 |
|
MD5 | 8e9be2025dd60374d7387b1aa73d3382 |
|
BLAKE2b-256 | c825cb02691e9259668f7384dedccfa6ca5516529f3670b8f43b8b71f66d94f9 |