Commit Graph

115 Commits

Author SHA1 Message Date
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
jarekkar 72791787ea Add support for passing Configs to Dataclasses (#285)
* Add support for passing Configs to Dataclasses

* formatting and fixes

* move tests into dataclasses_config.py

* use inherit_config in create_model

fix #276
2018-12-27 17:54:17 +00:00
Samuel Colvin 94fc64f5e1 uprev pydantic and test deps 2018-12-25 22:55:18 +00:00
Samuel Colvin 2512f25df7 tweak 'Using Pydantic' (#326)
* tweak 'Using Pydantic'

* typo

* remove gitter
2018-12-25 21:32:05 +00:00
Sebastián Ramírez 96020e91f6 Add section "Based on Pydantic" with FastAPI (#323)
* Add section "Based on Pydantic" with FastAPI

* Update History

* Update Third-Party libraries section, based on the style of AIOHTTP

* Remove release History details
2018-12-23 12:15:26 +00:00
Sebastián Ramírez 81f155864e Fix schema for timedelta as number, instead of str (#325) 2018-12-23 12:13:29 +00:00
Samuel Colvin 7a06736ead Add additional parameters to Schema for validation and annotation (#319)
* Add additional parameters to Schema for validation and annotation (#311)

* Add tests for validation declared via Schema class in defaults

* Add validations to field from declarations in Schema

* Add annotations in generated JSON Schema from validations via Schema

* Augment tests for schema generation

* Simplify validations from Schema in fields, from coverage hints

* Update schema test to use the spec plural "examples"

* Add docs and simple example of the additional parameters for Schema

* Update history

* Fix number of PR in HISTORY

* Refactor check for numeric types, remove break to make coverage happy

* Fix typo in docs, I confused gt with maximum

* Finish docstring for Schema (I had forgotten about it)

* Implement code review requests and lenient_issubclass with tests

* Move Schema to its now file to extract from fields.py but avoid circular imports

* Control coverage

* Schema fixes (#318)

* rearrange code

* cleanup get_annotation_from_schema

* fix typo

* rename _schema to schema
2018-12-03 12:37:39 +00:00
pyup.io bot a34cfd23da Scheduled monthly dependency update for December (#316)
* Update pygments from 2.2.0 to 2.3.0

* Update sphinx from 1.8.1 to 1.8.2

* Update coverage from 4.5.1 to 4.5.2

* Update pytest from 3.9.3 to 4.0.1

* Update pytest-sugar from 0.9.1 to 0.9.2
2018-12-03 09:32:37 +00:00
Jason Kuhrt a0aa9e78cd feat: add support for case insensitive env names (#313)
* feat: add support for case insensitive env names

Closes #277

* feedback: just alias os.environ

* doc: update history

* doc: mention case_insensitive option

* refactor: feedback if-else expression assignment

* fix: formatting

* chore: encode black configuration in file to support IDEs

* docs: fix example

* feedback: no suppport for IDEs in this PR

* feedback: style
2018-11-26 14:57:09 +00:00
Sebastián Ramírez 94706bc834 JSON Schema update/refactor/augment, to conform to spec (#308)
* Update schema tests to conform to JSON Schema spec

* Add JSON Schema tests for all supported types

including datetime and all supported Pydantic.types

* Add JSON Schema conforming schema sub module

* Update BaseModel to use schema module for JSON Schema generation

and update/simplify internal Schema methods

* Remove Schema code from Field class, replaced with JSON Schema module

* Add submodules to test model name generation for JSON Schemas

* Refactor/rewrite schema module to generate definions and refs

* Update and augment JSON Schema tests to include definitions and refs

and generation of a single JSON Schema with definitions from multiple (unrelated) models

* Add ref_prefix functionality to JSON Schema generation functions

* Test custom ref_prefix in JSON Schema generation

* Remove un-used BaseModel method, now refactored to schema module

* Update formating of test_schema

* Fix long lines in test_schema

* Fix imported but unused in fields

* Fix imported but unused in main.py

* Ignore imported but unused for testing modulec

* Refactor schema module for complexity

* Add conflicting name model to raise coverage

* Add conflicting model to test other flow and raise coverage

* Ignore complexity as destructuring more would make it more complex

and more difficult to understand, similar to .fields.validate

* Fix import sorting

* Update formatting with black, with CI settings

* Fix test for schemas with email validation

* Check if field is class before checking if is subclass

* Improve schema error when using unsuported types

* Add additional tests for corner cases, raise coverage to 100%

* Rename BaseModel.schema_json to schema_str (EAFP Python style)

* Add more tests to utils.display_as_type to increase the coverage for enums

* Remove unused catched error in schema tests

* Fix formatting with black

* Update docs schema example

* Add schema examples for top-level schema with multiple models

* Update docs, section Schema, with new JSON Schema generation details

* Update docs, history, with new features

* Update fields, remove unnecessary schema code for enums

* Update docs, fix links and typos in Schema section

* Trigger CI, as Python 3.7-dev seems to have random CI errors

* Revert Model.schema_str to Model.schema_json as requested

* Remove unnecessary assert in schema module as requested

* Remove annotations in internal functions, as requested

* Refactor get_flat_models_from_fields and reuse

* Use set short assignment syntax in schema module

* Remove unwanted assertion

* Make get_long_model_name a single line f-string

* Update model_name_map, add docstring and remove first return value

* Simplify dict operation in get_model_name_map as requested

* Make more concise model_name_map computation

* Remove bool from field check in schema as is subclass of int

* Make ref_prefix default to None and use global default

* Fix formatting for schema.py

* Refactor field_singleton_schema to use data structures

* Move main functions to top of schema, and add docstrings for them

* Implement __all__, move and order parts of schema

* Remove schema testing sub-package code as requested

* Generate schema testing subpackage in code

* Update schema tests with several related fields to use parametrized pytest

* Fix formatting and imports I missed after rebase

* Fix new formatting errors from CI

* Re-trigger Travis CI, Python 3.7-dev random error again, no re-run click in Travis for non owners

* Trigger annotation error with non-forward references

* Add docstrings for submodel schema

* tweaks and rewrite schema mapping table in python

* support complex defaults

* use str not int as dict keys

* Fix links to JSON Schema and OpenAPI
2018-11-22 16:00:06 +00:00
Guillermo cd50601172 Fix typos (#274) 2018-10-07 16:57:36 +01:00
Samuel Colvin 5089865857 uprev 2018-10-02 17:36:41 +01:00
pyup.io bot cdcf611f41 Scheduled monthly dependency update for October (#271)
* Update sphinx from 1.7.8 to 1.8.1

* Update mypy from 0.620 to 0.630

* Update pytest-cov from 2.5.1 to 2.6.0

* Update pytest-isort from 0.2.0 to 0.2.1
2018-10-02 17:34:46 +01:00
Samuel Colvin f3a278bb8d Dataclasses (#269)
* pydantic.dataclasses.dataclass decorator

* add dataclasses to requirnment.txt

* reimplement dataclasses

* fix linting, fix coverage

* docs
2018-10-01 09:48:28 +01:00
Stefan Gangefors c32ce342c9 Add support for deep copying of models (#261)
Using `model.copy(deep=True)` will deep copy a module instance.

Making a deep copy is useful for models that have lists of dicts or
any other non-simple data structure to not accidentally modify data
between instances.

`model.copy()` behaviour is unchanged and will do a shallow copy of
the model instance.

fix #249
2018-09-10 11:35:58 -04:00
pyup.io bot 9f874a7e97 Scheduled monthly dependency update for September (#256)
* Update sphinx from 1.7.6 to 1.7.8

* Update attrs from 18.1.0 to 18.2.0

* Update pytest from 3.7.2 to 3.7.4
2018-09-10 05:46:05 -04:00
Samuel Colvin c7c15bc415 fix json documentation (#253) 2018-08-29 10:38:02 +01:00
Samuel Colvin 0839646788 uprev 2018-08-25 17:15:22 +01:00
Samuel Colvin f46dc0c56f timedelta json encoding (#247)
* timedelta json encoding, altnative to #220

* history and tests

* fix comments and tests

* docs for json_encoders

* tests plain timedelta object parsing

* uprev

* tweak docs
2018-08-25 17:06:32 +01:00
Samuel Colvin e0a8dd2da8 issue and pull request templates, favicon 2018-08-25 16:49:36 +01:00
pyup.io bot f32ecf2258 Scheduled monthly dependency update for August (#240)
* Update sphinx from 1.7.5 to 1.7.6

* Update mypy from 0.610 to 0.620

* Update pycodestyle from 2.3.1 to 2.4.0

* Update pytest from 3.6.2 to 3.7.0

* uprev pytest

* reset pycodestyle
2018-08-20 12:03:54 +01:00
Nikita Grishko aad175a25f add `UrlStr and urlstr` types #236 (#246)
fix #236

* add ``UrlStr`` and ``urlstr`` types #236

* review fixes
2018-08-20 10:14:46 +01:00
Evghenii Goncearov a0e0aa4f79 Docs for json type (#228) 2018-07-11 15:08:51 +01:00
Samuel Colvin 1dc294015d cleaning up _populate_sub_fields, support tuples (#227)
* cleaning up _populate_sub_fields

* support tuples, fix #12

* fix, history and docs

* rename _create_sub_type
2018-07-10 18:45:15 +01:00
pyup.io bot 9f83ca48b9 Scheduled monthly dependency update for July (#217)
* Update sphinxcontrib-websupport from 1.0.1 to 1.1.0

* Update mypy from 0.600 to 0.610

* Update pycodestyle from 2.3.1 to 2.4.0

* Update pytest from 3.6.0 to 3.6.2

* revert pycodestyle agaaaain
2018-07-02 12:12:01 +01:00
Evghenii Goncearov 73015d2a72 Allow arbitrary types in model (#209)
* Allow arbitrary types in model

* Replaced ConfigError with RuntimeError

* Corrections of the ArbitraryTypeError exception class
2018-07-02 12:08:43 +01:00
Nikita Grishko d43ab483ee fix schema creation docs (#212)
* fix schema creation docs

* review fixes
2018-06-30 23:06:39 +01:00