* apply update_forward_refs to json_encoders, fix#3583
* linting
* mypy
* avoid use of ForwardRef with python3.6
* fix ForwardRef usage, take 2
* coverage
* 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>
* Remove `__root__` from BaseModel typing-only attrs
`__root__` is not a class variable nor is it always present.
The switch to `ClassVar` caused type errors to be reported in Pylance/Pyright.
* Add changelog entry
* Add support for removing TypeVarDef in mypy 0.920
* Add changes/3175-christianbundy.md
* type ignore on import
* 🤦
* coverage, again
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
* 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
* ✨ Add autocomplete support for VS Code, via dataclass_transform
* 📝 Update changes
* 📝 Add docs for VS Code
* 📝 Clarify strict type error checks alternatives, include example with cast()
* ♻️ Update BaseSettings annotation to improve editor support
keeping editor support for BaseSetting's custom Config, but preventing __config__ from showing in constructor on editors supporting dataclass_transform
* 🎨 Remove unused type: ignore comment
* 🎨 Update type annotations for BaseSettings and BaseModel to use ClassVar where suitable
to improve editor support with type annotations and dataclass_transform
* 🎨 Apply ClassVars again
* 📝 Simplify VS Code docs terms
refer mainly to Pylance and clarify the relationship with Pyright
* 📝 Add link to Pylance FAQ
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* 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.
* Added dark color scheme for docs
Added alternative, dark color scheme for docs, which should be automatically activated if user's browser presents the `prefers-color-scheme: dark` media query.
* switch icons
* add change file
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
* 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>
* Add a TypedDict class for error objects
This adds more specific typing for the dictionaries in
`ValidationError.errors()`. This shouldn't introduce any functional
change.
* quotes
* split required and not required keys
* type but be a class
* workaround cython (can't wait for v3)
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>