Commit Graph

141 Commits

Author SHA1 Message Date
Jan Vlčinský 7000a27d56 doc: self-referencing got note about rq for python 3.7+ (#618)
* doc: self-referencing got note about rq for python 3.7+

* Update HISTORY.rst

* Use issue # in history record
2019-06-24 14:37:54 +01:00
dmontagu b84df079a7 Add generic functionality (#595), fix #556
* Added generic functionality

* Skip tests in python 3.6

* double quote -> single quote

* Simplified, with more comprehensive tests

* double quote -> single quote

* Remove unintentional file

* Add caching

* don't cythonize generics.py

* Make work with mypy

* Remove __parameters__

* double quote -> single quote i'll remember one day

* More cleanup and validation

* Removed unwanted file

* A little more cleanup, and finish the PR

* Add proper inheritance

* Added note about inheritance to docs

* Added error for double-parameterizing

* Should build for python3.7

* Works with both 3.6 and 3.7

* Fixed bug with caching for single argument

* handle __name__ for generic models

* double quote -> single quote

* Updated error messages
2019-06-19 11:22:06 +01:00
Hmvp 1c45373f80 Add conlist type (#583)
* Add conlist type

* Fix cython issue

* Update pydantic/fields.py

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

* Update pydantic/types.py

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
2019-06-19 11:03:31 +01:00
Adamos Kyriakou 84820bdede Clarification around usage of Union (#594)
* Added two code examples on the correct and incorrect usage of `Union` in type annotations.

* Updated documentation.

* reST fix.

* Update docs/examples/union_type_incorrect.py

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

* Update docs/examples/union_type_incorrect.py

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

* Update docs/examples/union_type_incorrect.py

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

* Update docs/examples/union_type_correct.py

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

* PR comments.

* Updated `HISTORY.rst`.

* Update docs/index.rst

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

* Update HISTORY.rst

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

* Update docs/index.rst

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

* Update docs/index.rst

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>
2019-06-15 14:05:47 +01:00
cazgp eb1e640525 StrictBool (#580)
* StrictBool

StrictBool only allows booleans to be parsed. Any other value, no matter
its truthiness, is rejected.

* Fix type of `validate`

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

* " => '

* Update the exotic docs with StrictBool

* Fix error message

* Improve docs

* tweak docs.
2019-06-06 15:18:21 +01:00
Samuel Colvin 3dfae21208 ORM mode: Add support for arbitrary class instances (#562)
* Support ORM objects to 'parse_obj', replace #520

* switch to GetterDict and orm_mode

* tweaks

* update docs

* split tests and add @tiangolo's suggestion

* split tests and add @tiangolo's suggestion

* fix coverage
2019-06-06 11:29:09 +01:00
Sebastiaan Van Hoecke 2a04aa76b0 added feature post_init_post_parse (#567)
* added feature post_init_post_parse

* fixed bug where post_init_post_parse was triggered without looking is post_init_original is set

* change double to single quotes

* __doc__ strings fixed back to double quote

* added better way of doing the post_init_post_parse also tests passes now

* removed unused file

* deleted unnecessary test

* update history.rst, changed previouis change 560 to breaking change because it broke the original flow

* update docs, added section post_init_post_parse under dataclasses

* added __post_init_post_parse__ as attribute of DataclassType

* Update HISTORY.rst

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

* Update HISTORY.rst

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

* Update pydantic/dataclasses.py

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

* update docs, added subsection initialize hooks under dataclasses

* my bad

* make tests work again

* removed checking if post_init_parse is none

* correct typo in history

* fixed typo in history.rst
2019-06-04 10:01:09 +01:00
pyup.io bot d10f473732 Scheduled monthly dependency update for June (#570)
* Update pygments from 2.3.1 to 2.4.2

* Update sphinxcontrib-websupport from 1.1.0 to 1.1.2

* Update email-validator from 1.0.3 to 1.0.4

* Update isort from 4.3.17 to 4.3.20

* Update pytest from 4.4.1 to 4.6.0

* Update pytest-cov from 2.6.1 to 2.7.1
2019-06-03 09:44:21 +01:00
Samuel Colvin b248a0984f update benchmarks (#563)
* update benchmarks

* optimize
2019-05-30 12:43:44 +01:00
Samuel Colvin d473f4abc9 cython (#548)
* user cython for fields.py, parse.py and validators.py, fix #547

* fix coverage

* no cython on windows

* speedup error_wrappers, more cython

* conditional validators

* more tweaks to validators.py

* add compiled check

* fix mypy and tweak

* benchmark with cython

* simplify anystr_strip_whitespace

* build binaries on travis

* fix travis manylinux builds

* correct test stages

* cibuildwheel to dist

* fix manylinux build

* don't upgrade pip on wheel build

* try a fix for cibuildwheel

* speedup deploy stage

* revert file rearrangement, cythonize main.py

* tweak main.py

* update docs and history

* fix deploy stage of travis

* Cythonize more files (#553)

* Cythonize more files

* Tests pass

* Fixed ordering

* Some code cleanup

* Every last file cythonized

* cython coverage

* upgrade cython and tweak build setup

* different build stages
2019-05-30 12:04:15 +01:00
Sebastián Ramírez cd8c7641bf Fix JSON Schema for list, tuple, and set, improving interoperability (#540)
* Fix JSON Schema for list, tuple, and set, improving interoperatibility

* Update History with PR number
2019-05-23 10:18:46 +01:00
Samuel Colvin 22f134475d Colors (#516)
* Color validator MVP

* Color Validator refactored

* Small optimizations applied

* Code coverage improved

* hex processing improved, json encoder and repr added

* Add documentation, update HISTORY (#504)

* Increase test coverage (#504)

* hex helpers refactored (#504)

* Fixes after code review (#509)

* Color Type section in docs reduced

* Check for valid but unnamed colors

* Minor fixes: typo in docs, default value for float comparison function

* rewrite Color

* fix color tests

* tweaks and improve docs

* tweaks and change Color.__str__

* add as_hsla and as_hsl

* support more rgb(a) formats

* add hsl parsing

* parsing hex with alpha channel

* fix hsl parsing

* simpler failure/fallback rules for color display

* storage as floats internally

* tweak docs

* fix type hints
2019-05-22 13:14:35 +01:00
euri10 c0298a8a76 Fix to schema generation for IPv{4,6}{Address,Interface,Network} (#532)
* Fix to schema generation for IPv{4,6}{Address,Interface,Network}, fix #498

* Added docs

* Added PR number

* Updated format to comply with http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.3.4
Modified tests accordingly

* For real
2019-05-21 16:03:34 +01:00
pyup.io bot 983f886f77 Scheduled monthly dependency update for May (#499)
* Update sphinx from 2.0.0 to 2.0.1

* Update isort from 4.3.16 to 4.3.17

* Update mypy from 0.670 to 0.701

* Update pytest from 4.4.0 to 4.4.1

* Update pytest-mock from 1.10.3 to 1.10.4

* fix typing
2019-05-05 14:08:18 +01:00
Sean Marshallsay 8149e09332 Implement const keyword in Schema. (#469)
* feat: implement const keyword in Schema

Fix #434.

* make fields marked `const` optional

* move `const` out of the `Field`

* check that `schema` is not `None` instead of using `getattr`

* tweak constant error
2019-05-05 14:00:36 +01:00
theenglishway e5b8ec7750 improve doc on self-referencing models and annotations (#487) 2019-04-24 10:06:03 +01:00
Mike Goodspeed 0cfce77bb3 fix json for Path, FilePath, and DirectoryPath objects (#485)
* fix json for Path, FilePath, and DirectoryPath objects, fix #473

* convert to single spaces

* assert result to a string

* Update test_json.py

* encode entire Path hierarchy the same way
2019-04-23 15:09:09 +01:00
Andrew Sultana edafaf9b86 Fix ISO 8601 timedelta spec given in docs (#482) 2019-04-20 10:27:10 +01:00
primal100 50fd2c5b48 Validators for dataclasses (#454)
* Added validators for dataclass, fix #415

* Added dataclass validators

* Added dataclass validators

* Updated docs for added validating to dataclass

* Updated docs for added validating to dataclass

* Fixed line endings

* Set __validators__ type to Mapping instead of Dict

* Update History

* Use __mro__ instead of __bases__ for gather_validators

* Fix PR number

* Fix issue.rst header underline

* Fix HISTORY.rst merge conflict

* Fix utils.py merge conflict

* fix utils.py

* Rebase and other fixes

* Fix rebase and other issues

* Change history

* Remove unnecessary lines in main.py

* Rebase

* Update history

* Rename ModelType to ModelOrDc

* Added inheritance replace test

* More consiste dataclass validator tests

* fix history.

* Remove Optional ModelOrDc Type

* Fix ModelOrDc
2019-04-11 23:13:57 +01:00
Atheuz 449661b8cc fix: serialize secrets to json. (#465)
* fix: serialize secrets to json, fix #462

* feat: adjust documentation for secretstr.

* feat: undo unnecessary changes. keep tests.

* fix: tests were broken, now they're fixed again.

* feat: add display fn to SecretStr and SecretBytes, to be used for json output.

* fix: minor typo.

* fix: last few comments.
2019-04-11 19:32:28 +01:00
Atheuz a704662ae4 fix: miswritten output. (#461) 2019-04-04 17:46:34 +01:00
Atheuz 4a8faca42e feat: add SecretStr and SecretBytes. (#452)
* feat: add SecretStr and SecretBytes.

* chore: update HISTORY.rst

* fix: file permissions were incorrect.

* feat: lint, format, fix comments.

* feat: changed inner type of SecretBytes in the schema to string as there is no bytes type in json.

* feat: remove format from secret str and secret bytes.

* feat: fix schema mapping.
2019-04-04 12:14:47 +01:00
pyup.io bot 500a166056 Scheduled monthly dependency update for April (#449)
* Update sphinx from 1.8.4 to 2.0.0

* Update attrs from 18.2.0 to 19.1.0

* Update black from 18.9b0 to 19.3b0

* Update coverage from 4.5.2 to 4.5.3

* Update isort from 4.3.9 to 4.3.16

* Update pytest from 4.3.0 to 4.4.0

* Update pytest-isort from 0.2.1 to 0.3.1

* Update pytest-mock from 1.10.1 to 1.10.3
2019-04-02 10:44:26 +01:00
Vitaly R. Samigullin 8406bf04d1 Contributing section docs (#445)
* Minor updates to docs Contributing section

* Update HISTORY
2019-04-01 15:53:20 +01:00
Vitaly R. Samigullin 42bc8e4b43 Sequence support (#428)
fix #304

* Sequence support added

* Unittests for sequence added

* Fix HISTORY

* Sequence validation simplified

* Fix type conversion for Sequence
2019-03-29 10:17:23 +00:00
Sam Bristow 8e0bfa37ce Fix documentation for IPvAny* schema mappings (#433)
I think this was just a typo and these schemas support both IPv4 and IPv*6*.
2019-03-25 10:20:10 +00:00
Vitaly R. Samigullin cd39ade9ec datetime types docs added (#431)
* datetime types docs added

* datetime docs format changed
2019-03-23 10:51:34 +00:00
Nejc Zupan ac99083a82 Tiny typo (#427) 2019-03-21 00:47:50 +00:00
Vitaly R. Samigullin 0458f9ece9 IPv{4,6,Any}{Interface,Network} types added (#419)
* IPv{4,6,Any}{Network,Interface} types added, unittests and docs updated

* HISTORY.rst minor update

* Remove strict argument from IP network types

* IP Networks validators and type hints fixed

* tweak history
2019-03-20 18:13:04 +00:00
pyup.io bot 721f17d2b5 Scheduled monthly dependency update for March (#410)
* Update sphinx from 1.8.3 to 1.8.4

* Update flake8 from 3.7.4 to 3.7.7

* Update isort from 4.3.4 to 4.3.9

* Update mypy from 0.660 to 0.670

* Update pyflakes from 2.1.0 to 2.1.1

* Update pytest from 4.2.0 to 4.3.0

* Update pytest-mock from 1.10.0 to 1.10.1
2019-03-15 11:37:52 +00:00
Vitaly R. Samigullin f41e3afaa0 ipaddress.IPAddress support (#417)
* ipaddress-compatible types added, fix #333

* Unittests for ipaddress-types added

* Docs updated after ipaddress-types added

* HISTORY.rst updated to reflect ipaddress-related types introduction

* Fix docs table format

* Strings double quotes reverted

* ipaddress types support fixed, IPvAnyAddress type redefined

* Error handling fixed for ipaddress-related types

* Positive cases for IPv4Address and IPv6Address types in unittests added
2019-03-15 10:18:06 +00:00
Samuel Colvin 1161df3ca0 support ForwardRef on dataclasses (#399)
* support ForwardRef on dataclasses, fix #397

* explicit docs about when postponed annotations don't work
2019-02-18 08:41:35 +00:00
Samuel Colvin 27323aa8b2 fix for python 3.8 (#396)
* fix for python 3.8

* history and tweak types in main.py
2019-02-15 18:29:13 +00:00
Daniel Smith 96e3e74262 Tracking for setting attributes (#389)
fix #378

* Tracking for setting attributes

* Fixes accidental leak of fields

* Allows defaults fields to be recursively set

* Docs and history for skip_defaults

* Mypy fix on calculate keys

* Update pydantic/main.py

Co-Authored-By: dgasmith <dgasmith@icloud.com>

* Update pydantic/main.py

Co-Authored-By: dgasmith <dgasmith@icloud.com>

* Update HISTORY.rst

Co-Authored-By: dgasmith <dgasmith@icloud.com>

* Cleanup pass based off review

* Simplifies constructors based on feedback

* Makes mypy happy with exlicit KeysView

* SetOrKeys and faster key search

* Formats files once more

* add tests for dict, pickle and construct

* fixes for dict, pickle and construct

* correct field_set for extra.ignore

* Fixes format
2019-02-13 15:10:45 +00:00
Samuel Colvin baade9a117 rebuild validator arguments (#388)
* rebuild validator arguments

* cleanup and tests

* update docs
2019-02-13 10:31:36 +00:00
Samuel Colvin 9ef401839b add type hints (#373)
* add type hints, fix #372

* fix tests and BaseModel inference

* fix #280

* fix dataclasses and docs

* more typing

* adding hints to fields.py

* type **EVERTHING*

* fix for 3.6

* small speed ups and some typ checks

* correct model.copy

* update history
2019-02-04 21:54:20 +00:00
Or Carmi 9900c7f00c Refactored extra types to use a single enum (#352)
deprecated `ignore_extra` and `allow_extra` Config fields in favor of `extra`, fix #352

* refaactored extra types to use a single enum

* slightly simplified

* added tests

* fixed most stuff

* docs and some simplifications

* better assert

* changed enum and fixed logic

* trying to capture deprecation warning

* make format

* fixing tests and moving exta logic to __new__

* set_extra tests

* fox benchmarks

* formatting

* updated history

* docs

* added a negative tests

* reverted format changes

* format

* matched casing

* renamed values

* more fixes

* forgot values change

* another one

* weird stuff

* linting issue

* Update pydantic/main.py

Co-Authored-By: liiight <4374581+liiight@users.noreply.github.com>
2019-02-04 13:15:07 +00:00
Stephen Brown II 61e758965c Add multiple_of attribute to constrained numerics (#371)
* Add multiple_of attribute to constrained numerics

* Update HISTORY.rst

* make format

* Change limit_value -> multiple_of
2019-02-03 17:13:27 +00:00
James Bradshaw 67c965fb50 Fix typo in index.rst (#383) 2019-02-03 17:10:54 +00:00
Artem Malyshev 987449a922 Support typing.Callable validation. (#364)
fix #279

* Support typing.Callable validation.

* Add myself to HISTORY.

* Prove it works with just Callable.

* Document callable validator behavior.

* Support differences in typing module between py36 and py37.

* Remove callable filed from JSON schema with warning.

* Update pydantic/schema.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Update tests/test_callable.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Update pydantic/validators.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Update tests/test_callable.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Move callables to the exotic types.

* Move Callable type choice to the import time.

* Move is_callable_type to the utils module.

* Raise warning at skip except.

* Update pydantic/schema.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Update docs/index.rst

Co-Authored-By: proofit404 <proofit404@gmail.com>

* Update pydantic/schema.py

Co-Authored-By: proofit404 <proofit404@gmail.com>

* uprev

* Update index.rst (#370)

* Update history.rst

* Make the example a little more concise.

* Use callable import from the utils.

* Remove blank line.

* Remove duplication comments.

* fix history
2019-01-29 15:42:00 +00:00
Daniel Smith 39dd347607 Update index.rst (#370) 2019-01-26 17:55:29 +00:00
Nikita Grishko 145f04cb5d add `ConstrainedBytes and conbytes` types #315 (#357)
fix #315
2019-01-17 13:57:49 +00:00
Samuel Colvin 3c3c0262c0 add contributing docs, (#354)
* add contributing docs, fix #353

* tweaks

* tweaks
2019-01-11 21:08:14 +00:00
Samuel Colvin 25b5d98030 support postponed annotations and ForwardRef in python 3.7 (#348)
* support postponed annotations in python 3.7

* support for full ForwardRef

* tweak update_forward_refs

* better ForwardRef resolution

* remove debug, fix linting

* fix comments

* docs and history
2019-01-11 21:01:07 +00:00
Samuel Colvin dd202998bd improve docs for allow_extra and ignore_extra, fix #301 (#345) 2018-12-29 12:32:50 +00:00
Samuel Colvin 19320bf775 improve settings priority, (#343)
* improve settings priority, ref #341

* add HISTORY.rst

* move is_complex and rename _build_environ

* tweak
2018-12-29 12:31:53 +00:00
Samuel Colvin b43b887ec3 docs typo 2018-12-28 16:11:00 +00:00
Samuel Colvin eeb48fbeac don't call validators on keys of dictionaries, fix #254 (#342) 2018-12-28 16:07:48 +00:00
Samuel Colvin 9ad1a0ad24 reame get_validators > __get_validators__ (#338)
* reame get_validators > __get_validators__

* update docs
2018-12-27 20:30:41 +00:00
Samuel Colvin 8301f9e4b2 dataclass validation (#334)
* dataclass validation, fix #273

* support for tuple or dict in dataclasses

* tweaks

* adding example in docs
2018-12-27 19:15:39 +00:00