Commit Graph

562 Commits

Author SHA1 Message Date
Samuel Colvin cb262daddd fix ValidationError.json() (#922) 2019-10-23 10:27:55 +01:00
dmontagu 6b5adcc977 Rename skip-defaults, and add ability to exclude actual defaults (#915)
* Rename skip-defaults, and add ability to exclude actual defaults

* Add __defaults__ and deprecation warnings

* Add note about `skip_defaults` to docs

* Incorporate feedback

* Add tests and changes

* Fix reference to .json()
2019-10-23 10:14:51 +01:00
Samuel Colvin f5cde39e75 ConstrainedList improvements, fix #913 (#917) 2019-10-21 12:15:54 +01:00
dependabot-preview[bot] c7121ded2f Bump email-validator from 1.0.4 to 1.0.5 (#916)
Bumps [email-validator](https://github.com/JoshData/python-email-validator) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/JoshData/python-email-validator/releases)
- [Commits](https://github.com/JoshData/python-email-validator/compare/v1.0.4...v1.0.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-21 09:21:43 +01:00
Samuel Colvin 7db098fa49 get item type in get_annotation_from_field_info (#909)
* get item type in get_annotation_from_field_info, fix #779

* check constraints are enforced

* add change

* tests for phony constraints

* rewrite get_annotation_from_field_info

* fix tests

* add constaint enforcement to docs

* fix get_annotation_from_field_info coverage

* fix linting

* update docs as per @tiangolo suggestions
2019-10-18 17:41:10 +01:00
Samuel Colvin 78921da353 better str and repr for ModelField (#912)
* better str and repr for ModelField, fix #505

* better type display, fix tests

* correct _type_display signature

* fix for python3.6 differences

* fix PyObjectStr

* fix coverage
2019-10-18 14:32:30 +01:00
nu_no ca1fa934ec Add installation from repository (#900)
It think it's a good idea given that some features that are mentioned in the documentation (such as `root_validator`) are not yet in the current PyPI version.
2019-10-18 10:35:19 +01:00
dependabot-preview[bot] 2427f635e8 Bump mypy from 0.730 to 0.740 (#910)
* Bump mypy from 0.730 to 0.740

Bumps [mypy](https://github.com/python/mypy) from 0.730 to 0.740.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.730...v0.740)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* remove unused 'type: ignore'
2019-10-17 15:33:14 +01:00
Trim21 afba60f112 update docs for bool to match code (#911)
* update docs for bool to match code

* add changelog
2019-10-17 14:57:56 +01:00
Samuel Colvin ed7b216e5f Change alias precedence to prefer child models (#904)
* Change alias precedence to prefer child models

* add docs about alias precedence

* correct change
2019-10-17 10:58:28 +01:00
Samuel Colvin 87fb5cce12 change CI to 3.8 (#902)
* change CI to 3.8

* fix linting

* travis jobs for 3.8

* redo noqa comments

* add 3.8 to azure
2019-10-17 10:01:27 +01:00
Ivan Dmitrievsky 806eba3810 Merge init_kwargs with env variables recursively to handle nested values (#891)
* Merge init_kwargs with env variables recursively to handle nested values

This commit implements `deep_update` function that works as standard
`update` method on dicts, but also recursively updates all the nested
dict values. It allows splitting init arguments between environment
variables and in-code values, as long as they create a valid object
when merged together.

* Add entry to changes directory

* Fix CI/CD checks

* Make deep_copy not mutating, improve tests and type annotations
2019-10-15 11:24:46 +01:00
Samuel Colvin 6cda388c7a exclude unused files from docs (#896) 2019-10-15 00:16:27 +01:00
Ashton Shears b1e61b415a change secret types example (#890)
* change secret types example

* add changes file

* add address review comments

* remove redundant str() call
2019-10-14 18:00:37 +01:00
Samuel Colvin c3098a30cf Consistent __repr__ and __str__ methods for all types (#884)
* Consistent __repr__ and __str__ methods for all types

* add change description

* devtools integration and feedback on repr methods

* fix Color repr

* tests for truncate

* add devtools section to docs

* tests for devtools

* ValidationError inheriting from Representation

* fix imports

* tweaks

* tweak docs

* exec_examples.py integration with __repr__ changes
2019-10-14 17:37:04 +01:00
Samuel Colvin e7227db41a Insert prints in docs. (#895)
* starting insert prints

* working exec_script

* remove prints, fix exec_examples.py

* more cleanup of examples, better model printing

* upgrade netlify runtime

* extra docs deps

* few more small tweaks
2019-10-14 16:40:25 +01:00
retnikt 97b163db5f fix formatting for datetime nested bullet points in docs/usage/types.md (#887) 2019-10-11 17:26:02 +01:00
Samuel Colvin d6d8d7f9ed correct command formatting in docs/usage/mypy 2019-10-11 17:13:43 +01:00
Samuel Colvin d381fe84c6 deprecate case_insensitive on BaseSettings config (#885) 2019-10-11 15:59:02 +01:00
Samuel Colvin d0c6ec7009 deprecate Model.fields for Model.__fields__ (#883)
* deprecate Model.fields, use Model.__fields__

* correct docs
2019-10-11 11:10:02 +01:00
Samuel Colvin 41d79de3a9 fix subtle issue with settings env variables (#882) 2019-10-10 13:24:50 +01:00
Samuel Colvin bd8918bfab use FutureWarning in settings so it's printed (#881)
* use FutureWarning in settings so it's printed

* fix tests

* better warning link

* change warning link
2019-10-10 13:24:23 +01:00
Samuel Colvin f3dd39c1bb Few more tweaks to docs (#879) 2019-10-10 12:10:39 +01:00
dmontagu beb57364d2 Lots of minor docs tweaks (#877)
* Lots of minor changes

* More tweaks

* Remove git conflicts

* suggested tweaks
2019-10-10 12:00:22 +01:00
Koudai Aono 46db1efdfc Fix field of a type that has a default value (#880)
* fix type field

* update changes

* add testcase

* separate test for type fields
2019-10-09 14:06:15 +01:00
retnikt 6a0e5313cb Fix #867 by accepting and passing on **kwargs in ModelMetaclass.__new__ (#868)
* Fix #867 by accepting and passing on **kwargs in ModelMetaclass.__new__

pydantic.main.MetaModel.__new__ should include **kwargs at the end of
the method definition and pass them on to the super call at the end in
order to allow the special method __init_subclass__ to be defined with
custom parameters on extended BaseModel classes.

* MetaModel -> ModelMetaclass

* shrink change notes

* rename and reformat change description
2019-10-08 11:10:43 +01:00
dependabot-preview[bot] f08e40642a Bump mkdocs-material from 4.4.2 to 4.4.3 (#876)
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 4.4.2 to 4.4.3.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/4.4.2...4.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-08 11:09:51 +01:00
Samuel Colvin 4762f49b36 prepare v1.0b2 2019-10-07 18:46:37 +01:00
Samuel Colvin ae34a6a733 rename allow_population_by_alias -> allow_population_by_field_name (#875)
* rename allow_population_by_alias -> allow_population_by_field_name, fix #585

* add change

* tweak PR template ☣️

* tweak Makefile
2019-10-07 18:40:01 +01:00
dmontagu 9667478376 Make strictbool typecheck as bool (#873)
* Make strictbool typecheck as bool

* Incorporate feedback

* Remove unneeded pragma: no cover
2019-10-07 18:39:09 +01:00
dmontagu 09baf53dc9 Add support for custom naming schemes for GenericModel subclasses (#860) 2019-10-07 18:37:39 +01:00
dmontagu 425fac6343 Automatically add no-cover to TYPE_CHECKING blocks (#874)
* Automatically add no-cover to TYPE_CHECKING blocks

* Add changes file
2019-10-07 18:02:34 +01:00
Samuel Colvin 33b7d52d31 moving docs to mkdocs (#856)
* moving docs to mkdocs

* transfering readme to md and more

* fixing build

* splitting usage.md

* improving schema.md and index.md

* fix make_history.rst

* models intro

* working on data conversation and required fields

* more fixes to models.md

* list all standard types supported

* list of pydantic types

* tweaks

* update links in code

* Apply suggestions from code review

incorporate @dmontagu's suggestions.

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>

* Apply suggestions from code review

more missed suggestions.

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>

* Apply suggestions from code review

more corrects.

* cleanup

* Field order warning

* fix and regenerate benchmarks

* format examples better, cleanup

* improve schema mapping table

* correct highlighting file types in schema.md

* add redirects in javascript

* add logo
2019-10-07 17:19:01 +01:00
dependabot-preview[bot] 8905e9a53c Bump pytest-mock from 1.11.0 to 1.11.1 (#872)
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v1.11.0...v1.11.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 12:20:38 +01:00
dependabot-preview[bot] e3787821b3 Bump pytest from 5.2.0 to 5.2.1 (#871)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/5.2.0...5.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 12:20:21 +01:00
dependabot-preview[bot] f9344ed284 Bump pytest-cov from 2.7.1 to 2.8.1 (#870)
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.7.1 to 2.8.1.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.7.1...v2.8.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 10:16:49 +01:00
dependabot-preview[bot] 799cd370fe remove explicit attrs dependency (#855)
remove explicit attrs dependency
2019-10-02 14:23:46 +01:00
Samuel Colvin 8dabb34390 Version 1 beta (#853)
* link to old docs, uprev

* generate history
2019-10-01 17:41:33 +01:00
Samuel Colvin 6e5a1363cc V0.32 merge (#852)
* fix(validate-assignment): do not validate extra fields when `vaidate_assignment` is on

* Update history

* Fix `value` vs. `value_`

* Add tests for `value` vs `value_` case

* uprev

* Fix generic required (#742)

* Fix required fields on GenericModel

* lint

* version up

* __post_init__ with inheritance, fix #739 (#740)

* Fix custom Schema on GenericModel fields (#754)

* Fix custom Schema on GenericModel fields

* Add PR#

* uprev

* Fix error messages for Literal types with multiple allowed values (#770)

* Fix error messages for Literal types with multiple allowed values

* Incorporate feedback

* update history
2019-10-01 17:22:05 +01:00
Samuel Colvin 8f29837703 small bits of cleanup (#851)
* small tweaks to main.py

* add changes

* correct ModelMetaclass name

* fix password and user on AnyUrl
2019-10-01 17:08:30 +01:00
Samuel Colvin 9a5b411016 change how env variables work with settings (#847)
* change how env variables work with settings, fix #721

* inheritance and alias warnings

* update docs

* tweak env_settings.py
2019-10-01 16:32:02 +01:00
Samuel Colvin 6198343d9b Make history (#850)
* adding make_history.rst

* add to history

* fix on python3.6
2019-10-01 16:21:11 +01:00
Matthias 3ce16edbe2 Extend dataclass doc (#848)
* Add note detailing dataclass vs BaseModel usage

* Add changes rst describing the change
2019-10-01 15:51:37 +01:00
Samuel Colvin 12f4e0d082 rename Schema to Field (#824)
* rename Schema to Field

* add Schema function with deprecation warning

* mypy tests and other tweaks

* tweaks and cleanup

* Update pydantic/fields.py

Co-Authored-By: Sebastián Ramírez <tiangolo@gmail.com>
2019-09-30 17:49:59 +01:00
Samuel Colvin 1d0d98ba19 Root validators (#817)
* root validators and rename __obj__ -> __root__

* implement root validation

* tweak Validator

* dataclass and generic tests, docs

* repeat and signature checks

* fix inheritance

* tweaks tests and var names

* improvements to 'from_orm' to work better with root validators (#822)

* improvements to 'from_orm' to work better with root validators

* cython compatibility and tweaks

* tweak config order

* added test for derived classes using custom getter_dict config (#833)

* added test for derived classes using custom getter_dict config

* fix linting

* fix formatting

* cleanup
2019-09-30 17:19:44 +01:00
Samuel Colvin 973de05a01 custom json (de)serialisation (#823)
* custom json (d)encoders, fix #714

* add docs
2019-09-30 14:34:30 +01:00
Spencer Ellinor 253983559b Support use of TypeVar on generic subclasses (#842)
* Add failing generic subclass test

* Only raise type parameter failure on base GenericModel class

* Add changes to describe PR #842

* Change the class check to use is

* Fix formatting in subclass test

* correct change
2019-09-30 14:30:14 +01:00
Zaar Hai 6f97c0f9f7 Fixed example with datetime JSON encoder (#846) 2019-09-30 14:08:41 +01:00
dependabot-preview[bot] 9981a9fa0c Bump pytest-mock from 1.10.4 to 1.11.0 (#843)
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 1.10.4 to 1.11.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/1.10.4...v1.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-30 14:02:02 +01:00
dependabot-preview[bot] 83f408772d Bump pytest from 5.1.3 to 5.2.0 (#845)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 5.1.3 to 5.2.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/5.1.3...5.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-30 14:00:55 +01:00