Commit Graph

198 Commits

Author SHA1 Message Date
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 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
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
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 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 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 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
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 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 09baf53dc9 Add support for custom naming schemes for GenericModel subclasses (#860) 2019-10-07 18:37:39 +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
Samuel Colvin 8dabb34390 Version 1 beta (#853)
* link to old docs, uprev

* generate history
2019-10-01 17:41:33 +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
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
Zaar Hai 6f97c0f9f7 Fixed example with datetime JSON encoder (#846) 2019-09-30 14:08:41 +01:00
Samuel Colvin bc99825b60 improve benchmarks comment, fix #814 (#818) 2019-09-18 15:01:21 +01:00
Samuel Colvin 16263bafea None behaviour (#803)
* tweaks to None behaviour

* prevent sub_fields for Optional fields by default

* rewrite None validation

* rename whole > each_item on validators

* cleanup processing of the Json type

* fix schema coverage and cleanup

* tweak validate_model

* change and docs

* fix validators on optional fields

* coverage

* remove is_none_validator

* minor performance improvements to ErrorWrapper

* fix coverage

* fix PaymentCardNumber

* undo schema changes, fix

* tweak validators
2019-09-18 11:38:21 +01:00
Stephan Lanfermann 1b467da11f Added generic approach to strict type checking for constrained types (#799)
* Added generic approach to strict type checking for constraint types
- Use the arbitrary validator to build strict validators for ConstrainedInt, ConstrainedFloat, ConstrainedStr
- Make StrictStr a derived class of ConstrainedStr
- Add tests for new strict cases for ConstrainedInt and ConstrainedFloat

* - Created StrictInt and StrictFloat subclasses and exported them
- Changed strictness tests to use these new subclasses

* - Added section for Strict Types to docs

* - Added changes file

* Update docs/index.rst

Co-Authored-By: Zaar Hai <haizaar@users.noreply.github.com>

* Update docs/index.rst

Co-Authored-By: Zaar Hai <haizaar@users.noreply.github.com>

* - Create validators for strict int and float
- Make ConstrainedInt and ConstrainedFloat use those validators instead of abusing arbitrary type validator for strictness
- Prevent double validaton of same conditions by only yielding either the strict or non-strict type validator for for those classes

* Changed strict int and float tests to alos match for exception message in invalid cases

* - Removed obvious note about lack of ConstrainedBool
- Added example for strict type usage
- Added note about caveats for StrictInt and StrictFloat

* Update pydantic/validators.py

faster method to check if a value is boolean for strict int validator

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* - Removed StrictBool part from Boolean section of docs
- Moved the Strctbool code example into strict_types.py example file

* - Changed behavior of strictness for COnstrainedStr to match that fo other constrained types

* - Actually make ConstrainedStr use the correct validator for strictness
2019-09-17 12:38:51 +01:00
Matin Tamizi 0c5793770b PaymentCardNumber type (#790)
* initial proposal of payment card validation #788

* some cleanup for PaymentCardNumber #788

* fix linting issues

* tests and more robust errors #788

* fixed linting

* fixing mypy errors

* let's try this to make mypy work

* make consistent with cpython tests

* avoid using __new__

* use __init__ instead of properties

* clean up PaymentCardNumber.__init__

* use ClassVar where applicable

* add to changes/

* turns out this is never used

* get brand for other

* clean up a bit

* make PaymentCardNumber private

* use if/else to make faster in cython

* card_number => card number in errors

* make it clearer in the tests which exception is being raised

* parameterize tests for PaymentCardNumber

* lint

* clean up merge mistake from earlier

* fix mypy test error

* take out commented line

* update comment since code is moved

* docs for PaymentCardNumber

* clean up docs for PaymentCardNumber

* var name that makes more sense
2019-09-17 10:33:11 +01:00
Timon Ruban f08fd2fee7 Add support for Type[T] typehints when arbitrary_types_allowed==True. (#808)
* Add support for Type[T] typehints when arbitrary_types_allowe==True.

* Add documentation.

* Let black do its magic.

* Ignore mypy warning - see here: https://github.com/python/mypy/issues/3060

* Prettify docs.

* Change Changelog.

* Refactor and simplify check for Type[T].

* Black again. ^^ - Really need pre-commit hooks.

* Update pydantic/validators.py

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Rename arbitrary_class to class.

* Black.

* Add type hints.

* Make private function public.

* Add support for bare Type.

* Black again.

* Update docs.

* CO_ct not meant for export.

* Fix get_class for Python3.6

* Update error message of ClassError.

* Use relative import.

* Incorporate typing feedback (both versions are fine with mypy).

* Move from issubclass to lenient_issubclass.

* correct docs
2019-09-16 10:42:40 +01:00
Samuel Colvin 79017111aa new URL parsing (#755)
* new URL parsing, fix #603, fix #541

* AnyUrl parts and more tests

* more coverage and db DSNs

* remove DSN methods

* tests for urlstr

* remove debug

* make AnyStr a subtype of str

* fix with cython

* rearranging networking code

* allowing international domains, cleanup

* support international domains

* better URL builder

* allow underscores in subdomains and domains

* tests for json and schema, max length

* urlstr > stricturl

* updating docs

* tweak docs examples

* tweak docs
2019-09-02 11:37:33 +01:00
Matin Tamizi 00210716a7 used by Cuenca (#777) 2019-08-21 16:48:25 +01:00
Daniel Petti aa5e8c60b7 Feature/frozenset support (#762)
* Better error for unsuported "typing" objects.

Fixes #745

Add a better error message for fields with types from the typing
module that are not directly supported by Pydantic. Previously,
it caused a cryptic assertion failure.

* Add support for frozenset fields.

Also provide an example of their usage.

Fixes #745

* Address review comments.

Fixes #745

* use equals not "is" for int comparison.
2019-08-21 13:13:46 +01:00
dmontagu 756454fb58 Change defaults for BaseSettings (#747)
* Change defaults for BaseSettings

* Update docs and fix build

* Minor documentation fixes

* Fix lowercase issues

* Update docs and fix build

* Fix formatting

* Try with monkeypatched test

* Fix doublequotes

* Change case_insensitive to case_sensitive

* more change details.
2019-08-21 12:48:28 +01:00
pyup.io bot 6235ac2153 Update sphinx from 2.1.2 to 2.2.0 (#765) 2019-08-18 17:10:20 +01:00
dmontagu 65d838aa88 Serialize only __root__ value (#752)
* Serialize only __root__ value, fix #730

* Add changes and fix docs

* Clean up root model docs

* Update docs/index.rst

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Update docs/index.rst

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Rename variable

* fix rst in change description
2019-08-17 18:58:32 +01:00
dmontagu 27bb336545 Fix broken examples (#753)
* Fix broken examples

* Update changes
2019-08-17 13:03:53 +01:00
Koudai Aono 08c6af8ae2 add documentation for PyCharm Plugin (#750)
* add documentation for PyCharm Plugin

* add a change document for a history

* Delete typing.py

* update documents

* Apply suggestions from code review

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
2019-08-16 11:37:13 +01:00
Raphael de Carvalho Almeida 5b5451c02e Added initvars support to post_init_post_parse (#748)
* Added initvars support to post_init_post_parse

* Update change log with PR number

* Add practical initvars example to tests

* Update documentation
2019-08-16 09:36:56 +01:00
Abdussamet Koçak f41d5dca3c Support assert statements inside validators (#653)
* Support assert statements inside validators

* Add a validator example that uses assert

* Add warning about consequences of using -O optimization flag

* Fix a typo

* Fix incomplete validator

* Extend exception name generation

* Improve tests

* Clarify pytest behaviour

* handle assertion error name, fix build

* Address feedback

* docs cleanup

* Incorporate feedback

* fix quotes
2019-08-15 12:06:21 +01:00
dmontagu 321cde0c88 Include all annotated fields in order (#715)
* Include all annotated fields in order

* Update docs and changes

* fix field ordering

* update change info

* fix coverage
2019-08-12 12:05:22 +01:00
Samuel Colvin 82ef45c890 alter the behaviour of dict(model) so that sub-models are nolonger converted to dictionaries (#733)
* fix iteration to not convert to dict by default

* add change

* remove extra newline
2019-08-12 11:31:35 +01:00
dmontagu 72edca7532 Make bool_validator strict (#617)
* Make bool_validator strict

* incorporate feedback

* Add RelaxedBool

* Fix position in schema.py

* update BoolError message

* Incorporate feedback

* Update history

* Add changes

* Update docs/index.rst

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Update docs/index.rst

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Update tests/test_types.py

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* Incorporate feedback

* Update booleans.py

* Remove RelaxedBool

* tweak docs and update changes to new format
2019-08-10 12:00:29 +01:00
Samuel Colvin 485197c8e1 note about creating issue before PR 2019-08-06 16:25:38 +01:00
Samuel Colvin 9c8bba71c6 Preparation for Version 1 2019-08-06 16:19:38 +01:00
Sebastián Ramírez 3cb52b94d2 Fix double quotes to single quotes 2019-08-05 09:47:15 -05:00
Sebastián Ramírez 3bffe69fa5 Add schema_extra and title in docs for Config sub-class 2019-08-05 09:46:27 -05:00
Sebastián Ramírez a8ab92f382 Add example and docs for schema_extra in Config 2019-08-05 09:45:37 -05:00
Koudai Aono 45b4223ddb update README and History 2019-08-02 15:45:25 +09:00
dependabot-preview[bot] a9d9ba3e0a Bump docutils from 0.14 to 0.15.2
Bumps [docutils](http://docutils.sourceforge.net/) from 0.14 to 0.15.2.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-31 06:40:24 +00:00