Commit Graph

202 Commits

Author SHA1 Message Date
Brian Maissy a89c97a3e3 add a __call__ stub to PyObject for mypy (#1849)
Co-authored-by: Brian Maissy <brian@medigate.io>
2020-10-09 12:11:23 +01:00
Geon Kim - KimMachineGun be8ef63a33 docs: Fix incorrect description of copy method (#1821)
* docs: Fix typo

* docs: Fix incorrect description of copy method

* changes: Add changes description file

* docs: Add space before parentheses

Co-authored-by: PrettyWood <em.jolibois@gmail.com>

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
2020-10-09 11:28:04 +01:00
PrettyWood 75859a9d58 feat(tools): add parse_raw_as util (#1813)
closes #1812
2020-10-09 10:35:07 +01:00
PrettyWood 76fdbe92be feat(dotenv): support home directory relative paths (e.g. ~/.env) (#1804)
closes #1803

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-10-09 10:23:28 +01:00
Matthew Davis 094da94da9 clarify argument type to parse_file (#1795)
Co-authored-by: Matthew Davis <Matthew.Davis.2@team.telstra.com>
2020-10-08 21:10:09 +01:00
Selim Belhaouane b99c37e3d0 Fix #1770 (#1771) 2020-10-08 21:07:22 +01:00
PrettyWood 55e78cc106 fix(schema): add basic support of Pattern type in schema generation (#1768)
closes #1767
2020-10-08 20:42:14 +01:00
PrettyWood a2fc01a59b fix: forward ref with nested models and optional fields (#1752)
* fix: forward ref with nested models and optional fields

PR #1712 introduced a regression for forward refs in `ModelField.prepare`
as it would not return early for forward refs anymore.
Optional fields would hence have `required` set to `True`.

closes #1736

* test: skip python 3.6 as __future__.annotations is not defined
2020-10-08 20:26:30 +01:00
Samuel Colvin 9c4860ce96 Valdiate arguments config (#1663)
* add `configs` to validate_arguments

* simplify `validate_arguments` and add annotation for parameter `configs`

* change double quotes to single quotes

* reformat code

* fix mypy error

* fix mypy 'maximum semantic analysis' error

* rename 'configs' > 'config_params'

* change name and usage, start tests

* prevent setting fields on custom config

* add docs and fix mypy

* tweak docs

* add change

Co-authored-by: quantpy <quantpy@qq.com>
2020-09-06 23:17:52 +01:00
Yury Paykov 0a465b6216 Fix #1561 - apply Config env names for fields defined in the parent c… (#1585)
* Fix #1561 - apply Config env names for fields defined in the parent class

* Changes

* Fix lint

* Fix typing

* More tests
2020-09-06 16:51:38 +01:00
Samuel Colvin d2b050176e uprev 2020-07-15 20:24:20 +01:00
PrettyWood e2fcab52b9 fix: validate and parse nested models properly with default_factory (#1712)
* fix: validate nested models with `default_factory`

PR #1504 introduced a regression by bypassing `populate_validators()`,
which would skip the validation of children in nested models
with `default_factory`

closes #1710

* test: add example of nested models parsing with `default_factory`

closes #1717

* add testcase from #1722

* bodge for benchmarks

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-07-15 20:23:18 +01:00
Samuel Colvin 2440ab931e uprev and changes 2020-07-11 11:45:15 +01:00
Spiros Dontas 1f4ecd0785 Fix nested all include exclude (#1588)
* Fix nested all include exclude

* Ensure original exclude value is not modified

This commit also fixes some weird cases in the recursive
`update_normalized_all` call and Ellipsis values.

* Add docstring, parametrize tests
2020-07-11 11:28:53 +01:00
Samuel Colvin a913c37560 Fix master (#1682)
* Fix master

* Fix master 2 (#1694)

* test: add regression test with wrong type default

* fix: remove always on conlist and conset

* fix: use utf8 as default encoding on all OS

* conset invalid defualt test

* add change

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
2020-07-09 14:26:27 +01:00
flapili dac6764575 Url port check (#1678)
* add url port check

* add change

* Update pydantic/networks.py

fix typo

Co-authored-by: PrettyWood <em.jolibois@gmail.com>

* Update 1654-flapili.md

* Update 1654-flapili.md

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-07-03 20:56:36 +01:00
Patrick Wang dca98559d5 Add conset (#1627)
* Add conset

* Add changes doc

* Fix too-long lines

* bump

* Update conset change doc formatting

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Robustify test_conset

* Move conlist and conset tests to test_types

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-07-03 20:51:23 +01:00
beezee e3c5e1d3cd aggregate root validation errors (#1586)
* aggregate root validation errors

* add changelog

* update language in docs around root validators and prior failure

* factor out unique_list
2020-07-03 20:47:04 +01:00
John Carter ff20477521 Apply __modify_schema__ on enum schema rather than fields that use it (#1581)
* Apply __modify_schema__ on enum schema rather than fields that use it

Resolves #1576

* tweak test

* correct linting :-(

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-06-29 13:22:27 +01:00
ll H 8aebba2c35 check ModelField().validate_always when inheriting (#1545)
fix #1155

* fix issure #1155

* add changes.1545-dcHHH.md

* improve change description

Co-authored-by: dchhh <hudacong@geetest.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-06-29 11:04:44 +01:00
PrettyWood e5fff9ccd0 fix: make pydantic errors (un)pickable (#1630)
* fix: make pydantic errors (un)pickable

closes #1616

* add typing

* refactor: rename kwargs into ctx
2020-06-27 19:31:23 +01:00
Yuri Khan 908f6edb72 Document default regex anchoring semantics (#1631) (#1648) 2020-06-27 19:16:32 +01:00
Ram Rachum ecb54c5d36 Use chain.from_iterable in class_validators.py (#1642)
* Use chain.from_iterable in class_validators.py

* fix change

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-06-27 18:43:28 +01:00
Patrick Wang 5a2d78765a squash internal __root__ models in .dict() (#1607)
fix #1414

* flatten internal __root__ models

* add 1414 changes doc
2020-06-27 14:55:17 +01:00
Mlbiche 113921c6c5 Update datetime parser to support negative timestamps (#1605)
- Negative timestamps corresponds to dates before 1970/1/1
2020-06-27 14:52:20 +01:00
Samuel Eklund 7bd635c21c Subclass validator each item docs (#1592)
* add description of subclass each_item scenario

* add example of subclass validator with each_item

* each_item causes validator to not run when parent class has List field #1566
2020-06-27 14:51:18 +01:00
PrettyWood 7ac9faf031 (fix) use right type check when modifying schema (#1562)
fix #1552
2020-06-27 14:12:36 +01:00
PrettyWood c59db275dc fix(field): remove some side effects of default_factory (#1504)
* Avoid some side effects of default factory

- by calling it only once if possible (fix #1491)
- by not setting the default value in the schema (fix #1520)

* refactor: ensure type is set when using default_factory
2020-06-27 14:02:29 +01:00
Samuel Colvin d122b1dbdc remove RedisDsn.user_required = True (#1658)
* remove RedisDsn.user_required = True

* update docs
2020-06-26 12:02:57 +01:00
dependabot-preview[bot] 70d531ff4c Bump mypy from 0.770 to 0.780 (#1598)
* Bump mypy from 0.770 to 0.780

Bumps [mypy](https://github.com/python/mypy) from 0.770 to 0.780.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.770...v0.780)

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

* fix mypy errors and remove AnyType

* fix python 3.6 inconsistencies

* linting

* tweak typing

* fix typing for 3.6

* bump

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-06-25 19:24:37 +01:00
PrettyWood 0cee311be5 feat(settings): allow custom encoding for dotenv files (#1620)
closes #1615
2020-06-11 11:04:08 +01:00
PrettyWood 329b1d3e7b fix: type hints on BaseConfig (#1618)
closes #1614
2020-06-09 10:32:07 +01:00
wangpeibao 5e82689c79 Change schema frozenset (#1560)
* add frozenset to field_class_to_schema

* add change.md

* add my test

* format my test

* remove print()

* just test

* return to original code

Co-authored-by: wangpeibao <wangpeibao@troila.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-06-02 11:03:12 +01:00
Koudai Aono 6e29848608 Add datamodel-code-generator link in pydantic document site (#1532)
* Add datamodel-code-generator link in pydantic document site.

* tweak menu

* fix blank lines

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-05-31 15:23:20 +01:00
Shawn Wall 4f9e77d213 1541 UUID bytes support for 16 byte strings / BINARY(16) (#1542)
* [1541] add fallback to UUID instantiation through bytes

* [1541] added changes md file

* Update UUID docs for bytes/bytearray

Co-authored-by: Shawn Wall <shawn@civicscience.com>
2020-05-31 15:05:53 +01:00
John Carter 827388b4fe Add a test assertion that default_factory can return a singleton (#1523) 2020-05-31 14:51:50 +01:00
Alexander Hultnér 2eb62a3b2f Added a "Talks and video tutorials" section (#1499)
* Added a "Talks and video tutorials" section

Added my "Python pydantic Introduction – Give your data classes super powers" talk YouTube video based on the talk for Python Pizza.

* Add changelog entry for video change

Did this after creating the pr so I would have the number to use as a reference.

* Moved video into a discussion subsection

Now placed under testimonials

* Updated change log entry to reflect changes.
2020-05-26 07:50:56 +01:00
Calvin Young 5195e55c10 Enums as separate models (#1432)
* Updates schema() to generate enums as separate models

* Fixes mypy annotations

* Adds changes file

* Fixes comment

* Removes unused import

* Fixes test case

* Fixes missing partial branch in test coverage

* Resolves PR comments

* 🐛 Include enums in flat model schema handling

as they now have independent schemas, they kinda behave like top-level models, and should be taken into account for top level definitions

*  Add test for coverage

* 🐛 Use Type[Enum] as type for consistency

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-05-23 19:11:34 +01:00
Daniel Burkhardt Cerigo 913025ac3f FIX: validation on model attribute with nested Literal breaks (#1364)
* Add tests for nested literals validator

* Implement flatten literal in validator

* Add test for flatten literal

* Add changelog entry

* Add test skip markers if not Literal

* Refactor: use improved all literals implementation

From Github user PrettyWood, see PR https://github.com/samuelcolvin/pydantic/pull/1364

* Add testing for typing module

Includes moving corresponding tests.

* Remove unnecessary type hint

* Move all literals test to test_utils
2020-05-23 13:01:43 +01:00
Stephen Bunn 1eeb225c67 Fix NameEmail equality comparison (#1527)
* Adding appropriate __eq__ method for NameEmail

- Introducing new test assertions for NameEmail

Signed-off-by: Stephen Bunn <stephen@bunn.io>

* Adding change doc for NameEmail.__eq__

Signed-off-by: Stephen Bunn <stephen@bunn.io>

* Update pydantic/networks.py

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Update tests/test_networks.py

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>

* Fixing indentation issue left over from suggestion

Signed-off-by: Stephen Bunn <stephen@bunn.io>

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-05-19 08:59:33 +01:00
Mike Grima 28c2ac7a43 Added docs on dumping dataclasses to JSON (#1487) 2020-05-18 21:55:49 +01:00
Arseny Boykov 0b9b308ca5 Make signature class only (#1466)
* Make signature class only

* Add changes file
2020-05-18 21:41:24 +01:00
Selim Belhaouane 881df8bde7 move const validator to post validators. fixes #1410 (#1446) 2020-04-30 19:05:42 +01:00
Mostapha Sadeghipour Roudsari a4adf892dc Remove extra allOf keys in schema (#1438)
resolves #1209
2020-04-30 18:56:11 +01:00
Atheuz 9238e3d98f include format with secret types (#1424)
* include format with secret types

* fix: fix pr comments.

Co-authored-by: Lasse Gravesen <lasse.gravesen@falcon.io>
2020-04-30 13:09:45 +01:00
Jesse VanderWees 833d33dc0f ConstrainedFloat schema: differences between IEEE floats and json (#1422)
* ConstrainedFloat schema: account for differences between IEEE floats and json

* add changes

* Update changes/1417-vdwees.md

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

* Update changes/1417-vdwees.md

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

* fixup

* Update pydantic/types.py

Difference of styles :)

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

* merge _schema_ieee_compatibility_transform into parent method

* capitalize

* use type_, not outer_type_

Co-authored-by: Jesse VanderWees <jesse.vanderwees@kisters-bv.nl>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-04-30 13:08:23 +01:00
Samuel Colvin f96c4dc59f uprev 2020-04-23 13:43:34 +01:00
PrettyWood b2871468b7 Fix :: Signature generation with extra: allow never uses a field name (#1420)
* fix :: signature generation does not use field names

fix #1418

* fix :: use field.outer_type_ when generating signature

`extra_data: Dict[str, str]` would generate `extra_data: str` in the signature

* tweak to keep signature kwargs name

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2020-04-23 13:42:06 +01:00
PrettyWood 3cd8b1ee2d Fix :: avoid mutating Field default value (#1413)
fix #1412
2020-04-22 11:25:13 +01:00
Samuel Colvin 67acb659c2 prepare v1.5 release 2020-04-18 17:32:16 +01:00