* Fix info with in-place modification of field info
* add changes
* add test for 3714
* Update changes/4067-adriangb.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* fix: `Config.copy_on_model_validation` does a deep copy and not a shallow one
closes#3641
* fix: typo
* use python 3.10 to run fastapi tests
* fix fastapi test call
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
With CentOS 7 Python 3.6, running install from source with pip failed:
sudo podman run -ti --rm centos:7
yum -y update
yum -y install epel-release
yum -y install git python3 python3-devel python3-pip python3-setuptools python3-wheel
git clone https://github.com/samuelcolvin/pydantic.git
cd pydantic
pip3 install .
With following error message:
[root@c99d0585636c pydantic]# pip3 install .
Processing /pydantic
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-91v_ixvz-build/setup.py", line 62, in <module>
history = (THIS_DIR / 'HISTORY.md').read_text()
File "/usr/lib64/python3.6/pathlib.py", line 1197, in read_text
return f.read()
File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14648: ordinal not in range(128)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-91v_ixvz-build/
This PR add the required `read_text(encoding='utf-8')` for `setup.py`.
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
* 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.