* exclude extra field when represent model
* add test code
* fix W293
* add change md
* Update changes/3234-cocolman.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Update pydantic/main.py
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Update tests/test_main.py
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Small regression in #2231.
The shallow copy done with `Config.copy_on_model_validation = True` (default behaviour)
was using excluded / included fields when it should just copy everything
closes#3195
* Add RabbitmqDsn
Will update once finished - haven't looked at the CONTRIB yet. Want to test locally to see if it works.
* added tests; added to docs
* added changes
* fixed import in networks.py
* fixed linting issues; fixed __init__.py import issue
* sorted imports
* added trailing comma on imports
* Merge master
* Change class name from RabbitmqDsn to RabbitMqDsn
* Format code
* Rename change file and prettify content
* Fix RabbitMQ name on documentation
* Add a trivial test
* Address Samuel and Nuno's comments
* Refactor AMQP tests according to Redis tests style
* Update docs/examples/settings_main.py
* cleanup
Co-authored-by: Thomas <thomas@9bitbyte.com>
Co-authored-by: Thomas Crha <tom.crha@dragonflytechnologies.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Mention python >= 3.9.2 as an alternative to `typing_extensions.TypedDict`
* Narrow the upper version for `LegacyTypedDict`: 3.9 -> 3.9.2
* Add an entry to `changes`
* Update pydantic/annotated_types.py
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Update `TypedDict` exception message in the test suite
* linting
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* ✨ Add support for Decimal-specific configs in Field()
* ✅ Add/update tests for condecimal and variant with Field()
* 📝 Update schema - Field() docs including Decimal-specific configs
* 📝 Add PR changes file
* Add unit test for Union[int, Any]
* Allow None when Any or object is in Union
Resolves#3444
* Add changelog entry for #3444
* Prefer `is_none_type()` over `type_ is NoneType`
* fix(lint): remove useless import
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Add unique items validation to constrained list
* add unique_items to field and schema
add failover for unhashable types
check keyword value to call the validator
add some tests
* update unique_items validation
Co-authored-by: Nuno André Novo <nuno.novo@forensic-security.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* Replacing encode_default instance check with strict type check
* Adding change notes
* Changing to dictionary indexing in tests
* Adding explicit Enum check and returning its value
* Allow passing schema_overrides to get_field_info_schema
This function was resetting schema_overrides which prevents **extras on Enum type Fields
from being saved to their json schema
* Add changes file
* Update changes/2697-sammchardy.md
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Sam McHardy <sam.mchardy@psma.com.au>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Try to evaluate forward refs after model created
* Upadate docs and remove code duplication
* Update changes/2588-uriyyo.md
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Update docs/usage/postponed_annotations.md
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Remove unused import
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
* Derive concrete subclasses for parameterised generics
* Resolve type issues
* Add negative assertions to generic subclass tests
* Remove incorrect subclassing of partial.
The type was incorrectly being picked up for this style of subclassing,
and it can be regardless inferred through cls.
* Apply feedback:
* Improve parameterisation explanation
* fix typos
* Alias Parameterisation type
* Apply suggestions from code review
* start docstring with newline.
* Use None as default over empty tuple.
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Combine _assigned_parameters cases in __paramaterized_bases__ of generics
* Add description for the `_assigned_parameters` variable.
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* feat(schema): enforce length in generated JSON schema for tuple type
* docs: add change file
* docs: update documentation
* simplify a bit
* always set array
* Fix bug when mypy plugin fail on construct method call
* Update type annotation for __config__ field
* Remove type ignore
* Update changes/2753-uriyyo.md
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
Thanks to @PrettyWood for pointing me to the right place to fix this!
Since I was told that both NamedTuple and TypedDict use the same
__pydantic_model__ machinery that dataclasses do, I checked and found
that TypedDict had the same bug, and fixed that too.
Tests for both issues are included, which fail without the associated
fixes being applied.
* Parse JSON for union type with complex subfields (#2936)
* style
* simplify
Co-authored-by: Christopher Bartz <c.bartz@zbw.eu>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Add test for type hint subclass as default
* Fix support for using a subclass of an annotation as a default
* Add changes file
* add check in test
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* Fix: _pydantic_post_init() reassigns __dict__ and removes properties added to the object, for example in __new__(), breaking integration with SQLAlchemy and other libraries #3043
* Added changes file
* Fix 2860
When dealing with JsonWrapper, replace the inner type when constructing
a a generic model.
* tweak and schema test
Co-authored-by: PrettyWood <em.jolibois@gmail.com>