Version 1 release notes
After 2.5 years of development with contributions from over 80 people and 62 releases, pydantic has reached version 1!
While the fundamentals of pydantic have remained unchanged since the previous release v0.32.2 (indeed, since pydantic began in early 2017); a number of things have changed which you may wish to be aware of while migrating to Version 1.
What's new in pydantic v1🔗
A new decorator
root_validator has been added to allow validation of entire
Custom JSON encoding/decoding🔗
There are new
Config settings to allow
Custom JSON (de)serialisation. This can allow alternative
JSON implementations to be used with significantly improved performance.
The logic for parsing and validating boolean values has been overhauled to only allow a defined set of values rather than allowing any value as it used to.
The logic for parsing URLs (and related objects like DSNs) has been completely re-written to provide more useful error messages, greater simplicity and more flexibility.
Some less "clever" error handling and cleanup of how errors are wrapped (together with many other small changes) has improved the performance of pydantic by ~25%, see samuelcolvin/pydantic#819.
ORM mode improvements🔗
There are a number of changes to how
case_insensitivehas been renamed to
case_sensitiveand the default has changed to
case_sensitive = False
- the default for
env_prefixhas changed to an empty string, i.e. by default there's no prefix for environment variable lookups
- aliases are no longer used when looking up environment variables, instead there's a new
Improvements to field ordering🔗
There are some subtle changes to the ordering of fields, see Model field ordering for more details.
Schema renamed to Field🔗
The function used for providing extra information about fields has been renamed from
new name makes more sense since the method can be used to provide any sort of information and change the behaviour
of the field, as well as add attributes which are used while generating a model schema.
Improved repr methods and devtools integration🔗
__str__ method of models as well as most other public classes in pydantic have been altered
to be consistent and informative. There's also new integration with python-devtools.
Field constraints checks🔗
Constraints added to
Field() which are not enforced now cause an error when a model is created, see
Unenforced Field constraints for more details and work-arounds.