@@ -15,7 +15,7 @@ Data validation and settings management using python type hinting.
15
15
16
16
Define how data should be in pure, canonical python; validate it with * pydantic* .
17
17
18
- [ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) introduced type hinting into python 3.5,
18
+ [ PEP 484] ( https://www.python.org/dev/peps/pep-0484/ ) introduced type hinting into python 3.5;
19
19
[ PEP 526] ( https://www.python.org/dev/peps/pep-0526/ ) extended that with syntax for variable annotation in python 3.6.
20
20
21
21
* pydantic* uses those annotations to validate that untrusted data takes the form you want.
@@ -31,12 +31,12 @@ _(This script is complete, it should run "as is")_
31
31
32
32
What's going on here:
33
33
34
- * ` id ` is of type int; the annotation only declaration tells * pydantic* that this field is required. Strings,
35
- bytes or floats will be coerced to ints if possible, otherwise an exception would be raised.
36
- * ` name ` is inferred as a string from the default; it is not required as it has a default .
37
- * ` signup_ts ` is a datetime field which is not required (`` None `` if it's not supplied), pydantic will process
38
- either a unix timestamp int (e.g. ` 1496498400 ` ) or a string representing the date & time.
39
- * ` friends ` uses python's typing system, it is required to be a list of integers, as with ` id ` integer-like objects
34
+ * ` id ` is of type int; the annotation- only declaration tells * pydantic* that this field is required. Strings,
35
+ bytes or floats will be coerced to ints if possible; otherwise an exception will be raised.
36
+ * ` name ` is inferred as a string from the provided default; because it has a default, it is not required .
37
+ * ` signup_ts ` is a datetime field which is not required (and takes the value `` None `` if it's not supplied).
38
+ * pydantic * will process either a unix timestamp int (e.g. ` 1496498400 ` ) or a string representing the date & time.
39
+ * ` friends ` uses python's typing system, and requires a list of inputs. As with ` id ` , integer-like objects
40
40
will be converted to integers.
41
41
42
42
If validation fails pydantic will raise an error with
F438
a breakdown of what was wrong:
@@ -55,18 +55,18 @@ outputs:
55
55
So * pydantic* uses some cool new language features, but why should I actually go and use it?
56
56
57
57
** no brainfuck**
58
- : no new schema definition micro-language to learn. If you know python (and perhaps skim the
58
+ : there's no new schema definition micro-language to learn. If you know python (and perhaps skim the
59
59
[ type hinting docs] ( https://docs.python.org/3/library/typing.html ) ) you know how to use * pydantic* .
60
60
61
61
** plays nicely with your IDE/linter/brain**
62
- : because * pydantic* data structures are just instances of classes you define; auto-completion, linting,
63
- [ mypy] ( usage/mypy.md ) , IDEs (especially [ PyCharm] ( pycharm_plugin.md ) ) and your intuition should
62
+ : * pydantic* data structures are just instances of classes you define, so auto-completion, linting,
63
+ [ mypy] ( usage/mypy.md ) , IDEs (especially [ PyCharm] ( pycharm_plugin.md ) ), and your intuition should
64
64
all work properly with your validated data.
65
65
66
66
** dual use**
67
- : * pydantic's* [ BaseSettings] ( usage/settings.md ) class allows it to be used in both a "validate this request data"
68
- context and "load my system settings" context. The main difference being that system settings can have defaults
69
- changed by environment variables and more complex objects like DSNs and python objects are often required.
67
+ : * pydantic's* [ BaseSettings] ( usage/settings.md ) class allows * pydantic * to be used in both a "validate this request
68
+ data" context and in a "load my system settings" context. The main differences are that system settings can
69
+ be read from environment variables, and more complex objects like DSNs and python objects are often required.
70
70
71
71
** fast**
72
72
: In [ benchmarks] ( benchmarks.md ) * pydantic* is faster than all other tested libraries.
@@ -75,7 +75,7 @@ So *pydantic* uses some cool new language features, but why should I actually go
75
75
: use of [ recursive * pydantic* models] ( usage/models.md#recursive-models ) , ` typing ` 's
76
76
[ standard types] ( usage/types.md#standard-library-types ) (e.g. ` List ` , ` Tuple ` , ` Dict ` etc.) and
77
77
[ validators] ( usage/validators.md ) allow
78
- complex data schemas to be clearly and easily defined and then validated and parsed.
78
+ complex data schemas to be clearly and easily defined, validated, and parsed.
79
79
80
80
** extensible**
81
81
: * pydantic* allows [ custom data types] ( usage/types.md#custom-data-types ) to be defined or you can extend validation
@@ -96,27 +96,27 @@ Hundreds of organisations and packages are using *pydantic*, including:
96
96
97
97
** Microsoft**
98
98
: are using * pydantic* (via FastAPI) for
99
- [ numerous services] ( https://github.com/tiangolo/fastapi/pull/26#issuecomment-463768795 ) some of which are
99
+ [ numerous services] ( https://github.com/tiangolo/fastapi/pull/26#issuecomment-463768795 ) , some of which are
100
100
"getting integrated into the core Windows product and some Office products."
101
101
102
102
** Amazon Web Services**
103
- : are using * pydantic* in [ gluon-ts] ( https://github.com/awslabs/gluon-ts ) an open-source probabilistic time series
103
+ : are using * pydantic* in [ gluon-ts] ( https://github.com/awslabs/gluon-ts ) , an open-source probabilistic time series
104
104
modeling library.
105
105
106
106
** The NSA**
107
- : are using * pydantic* in [ WALKOFF] ( https://github.com/nsacyber/WALKOFF ) an open-source automation framework.
107
+ : are using * pydantic* in [ WALKOFF] ( https://github.com/nsacyber/WALKOFF ) , an open-source automation framework.
108
108
109
109
** Uber**
110
- : are using * pydantic* in [ Ludwig] ( https://github.com/uber/ludwig ) an an open-source TensorFlow wrapper.
110
+ : are using * pydantic* in [ Ludwig] ( https://github.com/uber/ludwig ) , an an open-source TensorFlow wrapper.
111
111
112
112
** Cuenca**
113
- : a Mexican neobank that uses * pydantic* for several internal
113
+ : are a Mexican neobank that uses * pydantic* for several internal
114
114
tools (including API validation) and for open source projects like
115
115
[ stpmex] ( https://github.com/cuenca-mx/stpmex-python ) , which is used to process real-time, 24/7, inter-bank
116
116
transfers in Mexico.
117
117
118
- For a more comprehensive list of open-source projects using * pydantic* see
119
- [ dependents on github] ( https://github.com/samuelcolvin/pydantic/network/dependents ) .
118
+ For a more comprehensive list of open-source projects using * pydantic* see the
119
+ [ list of dependents on github] ( https://github.com/samuelcolvin/pydantic/network/dependents ) .
120
120
121
121
<script >
122
122
{! ./ redirects .js ! }
0 commit comments