add support for annotation only fields (#41)

* add support for annotation only fields, fix #34

* adding tests with mypy

* adding docs for mypy usage

* adding mypy failure test

* adding alias tests

* tweak mypy tests
This commit is contained in:
Samuel Colvin
2017-06-07 19:56:46 +01:00
committed by GitHub
parent affea7a45d
commit c81ec9aeec
24 changed files with 247 additions and 26 deletions
+30
View File
@@ -0,0 +1,30 @@
from pydantic import ValidationError
try:
User(signup_ts='broken', friends=[1, 2, 'not number'])
except ValidationError as e:
print(e.json())
"""
{
"friends": [
{
"error_msg": "invalid literal for int() with base 10: 'not number'",
"error_type": "ValueError",
"index": 2,
"track": "int"
}
],
"id": {
"error_msg": "field required",
"error_type": "Missing",
"index": null,
"track": null
},
"signup_ts": {
"error_msg": "Invalid datetime format",
"error_type": "ValueError",
"index": null,
"track": "datetime"
}
}
"""