* 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>
* 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>
* Add (failing) test for Subclass JSON encoding
* Allow subclasses of known types to be encoded with superclass encoder
* Add change file
* Add documentation, fix custom json_encoders and add unit test
Blacken doc
Fix test that worked on my machine
datetime.timestamp() is flakey?
Single quotes only
* Reduce lookups
- Remove last element in `__mro__` as it will always be `object`
- Use .get for compactness
* Regarding the loop
* Move Path and Enum into ENCODERS_BY_TYPE
Sort ENCODERS_BY_TYPE
* improve JSON docs
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* make secret types idempotent
* remove idempotent from secret types example.
add note to docs for idempotently creating secret types.
use isinstance for comparing when creating secret types idempotently.
add assert for idempotent secret types test.
* tweaks
Co-authored-by: Lasse Gravesen <lasse.gravesen@falcon.io>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* ignore pyenv generated file
* Allow `None` as input to all optional list fields
* skip test on python 3.6
* fix mypy error, line length
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Have BaseModel inherit from Representation
This changes the inheritance so that `BaseModel` *actually* inherits from `Representation`, rather than just having the same methods as it. While this doesn't actually affect the runtime, it does make mypy happier.
Fixes https://github.com/samuelcolvin/pydantic/issues/1310
* Add '__dict__' back into slots
* Add change file
* Add datetime field to default_factory example
Print instead of assert
Remove bad quotes
Remove bad quotes from all examples
* fix change description
* remove 'avoid-escape' from setup.cfg
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Raise informative TypeError when passing bad exclude kwargs to export
* Cleanup spurious example
* Add __all__ keyword to enable excluding fields from all members of a list/tuple of child submodels
* Add changelog
* Fix MD format inconsistencies and consolidate export tests
* Excluding from exported List of Dict fields with "__all__"
* tweaks
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* update_forward_refs now modifies only a copy of __dict__ of cls.__module__
* changes
* test for update_forward_refs
* fixed brackets
* black changes fixed
* make format
Co-authored-by: Samuel Colvin <s@muelcolvin.com>