* refactor(schema): put schema data from fieldinfo in dedicated function
* feat(schema): support custom title, description and default for enums
closes#1748
* refactor: replace $ref by allOf + $ref to be supported by doc generation tools
* fix: do not set title by default for enums
* refactor: make code more explicit
* fix: run linter
* 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
* 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>
* 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
* 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>
* 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>
* 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
* 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
* 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>
* 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>
* 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.
* 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>
* 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
* 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>