Skip to content

Commit b8bbfec

Browse files
authored
release notes for v1 (pydantic#918)
* release notes for v1 * uprev and tweaks * Apply suggestions from code review Co-Authored-By: dmontagu <[email protected]> * tweak notes, add back link to old docs * build changelog
1 parent dccc401 commit b8bbfec

27 files changed

+126
-50
lines changed

HISTORY.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
## v1.0 (2019-10-23)
2+
3+
* **Breaking Change:** deprecate the `Model.fields` property, use `Model.__fields__` instead, #883 by @samuelcolvin
4+
* **Breaking Change:** Change the precedence of aliases so child model aliases override parent aliases,
5+
including using `alias_generator`, #904 by @samuelcolvin
6+
* **Breaking change:** Rename `skip_defaults` to `exclude_unset`, and add ability to exclude actual defaults, #915 by @dmontagu
7+
* Add `**kwargs` to `pydantic.main.ModelMetaclass.__new__` so `__init_subclass__` can take custom parameters on extended
8+
`BaseModel` classes, #867 by @retnikt
9+
* Fix field of a type that has a default value, #880 by @koxudaxi
10+
* Use `FutureWarning` instead of `DeprecationWarning` when `alias` instead of `env` is used for settings models, #881 by @samuelcolvin
11+
* Fix issue with `BaseSettings` inheritance and `alias` getting set to `None`, #882 by @samuelcolvin
12+
* Modify `__repr__` and `__str__` methods to be consistent across all public classes, add `__pretty__` to support
13+
python-devtools, #884 by @samuelcolvin
14+
* deprecation warning for `case_insensitive` on `BaseSettings` config, #885 by @samuelcolvin
15+
* For `BaseSettings` merge environment variables and in-code values recursively, as long as they create a valid object
16+
when merged together, to allow splitting init arguments, #888 by @idmitrievsky
17+
* change secret types example, #890 by @ashears
18+
* Change the signature of `Model.construct()` to be more user-friendly, document `construct()` usage, #898 by @samuelcolvin
19+
* Add example for the `construct()` method, #907 by @ashears
20+
* Improve use of `Field` constraints on complex types, raise an error if constraints are not enforceable,
21+
also support tuples with an ellipsis `Tuple[X, ...]`, `Sequence` and `FrozenSet` in schema, #909 by @samuelcolvin
22+
* update docs for bool missing valid value, #911 by @trim21
23+
* Better `str`/`repr` logic for `ModelField`, #912 by @samuelcolvin
24+
* Fix `ConstrainedList`, update schema generation to reflect `min_items` and `max_items` `Field()` arguments, #917 by @samuelcolvin
25+
* Allow abstracts sets (eg. dict keys) in the `include` and `exclude` arguments of `dict()`, #921 by @samuelcolvin
26+
* Fix JSON serialization errors on `ValidationError.json()` by using `pydantic_encoder`, #922 by @samuelcolvin
27+
* Clarify usage of `remove_untouched`, improve error message for types with no validators, #926 by @retnikt
28+
129
## v1.0b2 (2019-10-07)
230

331
* Mark `StrictBool` typecheck as `bool` to allow for default values without mypy errors, #690 by @dmontagu

changes/867-retnikt.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

changes/880-koxudaxi.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/881-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/882-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/883-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/884-samuelcolvin.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

changes/885-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/888-idmitrievsky.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

changes/890-ashears.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/898-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/904-samuelcolvin.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

changes/907-ashears.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/909-samuelcolvin.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

changes/911-trim21.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/912-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/915-dmontagu.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/917-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/921-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/922-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changes/926-retnikt.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/examples/example1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class User(BaseModel):
1111
external_data = {
1212
'id': '123',
1313
'signup_ts': '2019-06-01 12:22',
14-
'friends': [1, '2', 3.1415]
14+
'friends': [1, 2, '3']
1515
}
1616
user = User(**external_data)
1717
print(user.id)

docs/index.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77

88
{!.version.md!}
99

10-
!!! note
11-
These docs refer to Version 1 of *pydantic* which is as-yet unreleased. **v0.32** docs are available
12-
[here](https://5d584fcca7c9b70007d1c997--pydantic-docs.netlify.com).
10+
Data validation and settings management using python type annotations.
1311

14-
Data validation and settings management using python type hinting.
12+
*pydantic* enforces type hints at runtime, and provides user friendly errors when data is invalid.
1513

1614
Define how data should be in pure, canonical python; validate it with *pydantic*.
1715

18-
[PEP 484](https://www.python.org/dev/peps/pep-0484/) introduced type hinting into python 3.5;
19-
[PEP 526](https://www.python.org/dev/peps/pep-0526/) extended that with syntax for variable annotation in python 3.6.
20-
21-
*pydantic* uses those annotations to validate that untrusted data takes the form you want.
22-
23-
There's also support for an extension to [dataclasses](usage/dataclasses.md) where the input data is validated.
16+
!!! note "Version 0.32 Documentation"
17+
This documentation refers to Version 1 of *pydantic* which has just been released, **v0.32.2**
18+
(the previous release) docs are available [here](https://5d584fcca7c9b70007d1c997--pydantic-docs.netlify.com).
2419

2520
## Example
2621

@@ -51,17 +46,13 @@ outputs:
5146

5247
## Rationale
5348

54-
5549
So *pydantic* uses some cool new language features, but why should I actually go and use it?
5650

57-
**no brainfuck**
58-
: there's no new schema definition micro-language to learn. If you know python (and perhaps skim the
59-
[type hinting docs](https://docs.python.org/3/library/typing.html)) you know how to use *pydantic*.
60-
6151
**plays nicely with your IDE/linter/brain**
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-
all work properly with your validated data.
52+
: There's no new schema definition micro-language to learn. If you know how to use python type hints,
53+
you know how to use *pydantic*. Data structures are just instances of classes you define with type annotations,
54+
so auto-completion, linting, [mypy](usage/mypy.md), IDEs (especially [PyCharm](pycharm_plugin.md)),
55+
and your intuition should all work properly with your validated data.
6556

6657
**dual use**
6758
: *pydantic's* [BaseSettings](usage/settings.md) class allows *pydantic* to be used in both a "validate this request
@@ -80,7 +71,11 @@ So *pydantic* uses some cool new language features, but why should I actually go
8071
**extensible**
8172
: *pydantic* allows [custom data types](usage/types.md#custom-data-types) to be defined or you can extend validation
8273
with methods on a model decorated with the [`validator`](usage/validators.md) decorator.
83-
74+
75+
**dataclasses integration**
76+
: As well as `BaseModel`, *pydantic* provides
77+
a [`dataclass`](usage/dataclasses.md) decorator which creates (almost) vanilla python dataclasses with input
78+
data parsing and validation.
8479

8580
## Using Pydantic
8681

docs/usage/models.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ For self-referencing models, see [postponed annotations](postponed_annotations.m
121121
Pydantic models can be created from arbitrary class instances to support models that map to ORM objects.
122122

123123
To do this:
124+
124125
1. The [Config](model_config.md) property `orm_mode` must be set to `True`.
125126
2. The special constructor `from_orm` must be used to create the model instance.
126127

@@ -380,10 +381,10 @@ _(This script is complete, it should run "as is")_
380381

381382
!!! warning
382383
As demonstrated by the example above, combining the use of annotated and non-annotated fields
383-
in the same model can result in surprising field orderings. (This is due to limitations of python.)
384+
in the same model can result in surprising field orderings. (This is due to limitations of python)
384385

385386
Therefore, **we recommend adding type annotations to all fields**, even when a default value
386-
would determine the type by itself.
387+
would determine the type by itself to guarentee field order is preserved.
387388

388389
## Required fields
389390

docs/version_1_release_notes.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
After 2.5 years of development with contributions from over 80 people and 62 releases, *pydantic* has reached
2+
version 1!
3+
4+
While the fundamentals of *pydantic* have remained unchanged since the previous release
5+
[v0.32.2](changelog.md#v0322-2019-08-17) (indeed, since *pydantic* began in early 2017);
6+
a number of things have changed which you may wish to be aware of while migrating to Version 1.
7+
8+
Below is a list of significant changes, for a full list of changes see release notes for
9+
[v1.0b1](changelog.md#v10b1-2019-10-01), [v1.0b2](changelog.md#v10b2-2019-10-07),
10+
and [v1.0](changelog.md#v10-2019-10-23).
11+
12+
## What's new in pydantic v1
13+
14+
### Root validators
15+
16+
A new decorator [`root_validator`](usage/validators.md#root-validators) has been added to allow validation of entire
17+
models.
18+
19+
### Custom JSON encoding/decoding
20+
21+
There are new `Config` settings to allow
22+
[Custom JSON (de)serialisation](usage/exporting_models.md#custom-json-deserialisation). This can allow alternative
23+
JSON implementations to be used with significantly improved performance.
24+
25+
### Boolean parsing
26+
27+
The logic for [parsing and validating boolean values](usage/types.md#booleans) has been overhauled to only allow
28+
a defined set of values rather than allowing any value as it used to.
29+
30+
### URL parsing
31+
32+
The logic for parsing URLs (and related objects like DSNs) has been completely re-written to provide more useful
33+
error messages, greater simplicity and more flexibility.
34+
35+
### Performance improvements
36+
37+
Some less "clever" error handling and cleanup of how errors are wrapped (together with many other small changes)
38+
has improved the performance of *pydantic* by ~25%, see
39+
[samuelcolvin/pydantic#819](https://github.com/samuelcolvin/pydantic/pull/819).
40+
41+
### ORM mode improvements
42+
43+
There are improvements to [`GetterDict`](usage/models.md#orm-mode-aka-arbitrary-class-instances) to make ORM mode
44+
easier to use and work with root validators, see
45+
[samuelcolvin/pydantic#822](https://github.com/samuelcolvin/pydantic/pull/822).
46+
47+
### Settings improvements
48+
49+
There are a number of changes to how [`BaseSettings`](usage/settings.md) works:
50+
51+
* `case_insensitive` has been renamed to `case_sensitive` and the default has changed to `case_sensitive = False`
52+
* the default for `env_prefix` has changed to an empty string, i.e. by default there's no prefix for environment
53+
variable lookups
54+
* aliases are no longer used when looking up environment variables, instead there's a new `env` setting for `Field()` or
55+
in `Config.fields`.
56+
57+
### Improvements to field ordering
58+
59+
There are some subtle changes to the ordering of fields, see [Model field ordering](usage/models.md#field-ordering)
60+
for more details.
61+
62+
### Schema renamed to Field
63+
64+
The function used for providing extra information about fields has been renamed from `Schema` to `Field`. The
65+
new name makes more sense since the method can be used to provide any sort of information and change the behaviour
66+
of the field, as well as add attributes which are used while [generating a model schema](usage/schema.md).
67+
68+
### Improved repr methods and devtools integration
69+
70+
The `__repr__` and `__str__` method of models as well as most other public classes in *pydantic* have been altered
71+
to be consistent and informative. There's also new [integration with python-devtools](usage/devtools.md).
72+
73+
### Field constraints checks
74+
75+
Constraints added to `Field()` which are not enforced now cause an error when a model is created, see
76+
[Unenforced Field constraints](usage/schema.md#unenforced-field-constraints) for more details and work-arounds.

mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
site_name: Pydantic
1+
site_name: pydantic
22
site_description: Data validation and settings management using python 3.6 type hinting
33
strict: true
44
site_url: https://pydantic-docs.helpmanual.io/
@@ -25,6 +25,7 @@ extra_javascript:
2525
nav:
2626
- Overview: index.md
2727
- install.md
28+
- 'Version 1 release notes': version_1_release_notes.md
2829
- Usage:
2930
- usage/models.md
3031
- 'Field Types': usage/types.md
@@ -37,7 +38,7 @@ nav:
3738
- usage/postponed_annotations.md
3839
- 'Usage with mypy': usage/mypy.md
3940
- 'Usage with devtools': usage/devtools.md
40-
- Contributing to Pydantic: contributing.md
41+
- Contributing to pydantic: contributing.md
4142
- benchmarks.md
4243
- 'PyCharm plugin': pycharm_plugin.md
4344
- changelog.md

pydantic/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__all__ = ['VERSION']
44

5-
VERSION = StrictVersion('1.0b2')
5+
VERSION = StrictVersion('1.0')

0 commit comments

Comments
 (0)