Following #2000 and #2046 we can't `pop` the current value when assigning
a new one (which was probably the most efficient) as we want to keep the
order in the `__dict__`.
So let's do a shallow copy of the `__dict__` without the current value
fix#2073
* don't pop the value off __dict__
* adding change description
* still pop the field, but catch any exc, set the field to og value, and reraise exc
* adding tests
* fixing test
* improve tests/test_validators.py tests
Co-authored-by: John Sabath <john.sabath@equipmentshare.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* call validator with correct "values" type in BaseModel.__setattr__
* Fix code review comments
- use `self.__dict__` as the values parameter
- refine changed markdown
Co-authored-by: Ran Shaham <ransh@mobileye.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
* Added optional for root_validator to be skipped if values validation fails
* cleaner usage of skip_on_failure
* skip_on_failure: documentation update
* Implement Optional required, when creating a ModelField(required=True), make it persist
* Add test for nullable required
* Improve formatting of Undefined custom object
* Refactor field infer/creation with Undefined to make it idempotent
Needed for when _type_analysis is re-run in Generics
* Add PR changes
* Increment/update tests with code review
* Update/refactor Undefined implementation with code review
* Fix BoolUndefined as string type for mypy, not runtime
* Add docs about required Optional
* Add explicit tests for Any
* Apply code review requested changes
* move tests out of test_validators.py
* Add better support for validator reuse
* Clean up classmethod unpacking
* Add changes
* Fix coverage check
* Make 3.8 compatible
* Update changes/940-dmontagu.md
Co-Authored-By: Samuel Colvin <s@muelcolvin.com>
* Make allow_reuse discoverable by adding to error message
* switch _check_validator_name to _prepare_validator
* fix(validate-assignment): do not validate extra fields when `vaidate_assignment` is on
* Update history
* Fix `value` vs. `value_`
* Add tests for `value` vs `value_` case
* uprev
* Fix generic required (#742)
* Fix required fields on GenericModel
* lint
* version up
* __post_init__ with inheritance, fix#739 (#740)
* Fix custom Schema on GenericModel fields (#754)
* Fix custom Schema on GenericModel fields
* Add PR#
* uprev
* Fix error messages for Literal types with multiple allowed values (#770)
* Fix error messages for Literal types with multiple allowed values
* Incorporate feedback
* update history
* root validators and rename __obj__ -> __root__
* implement root validation
* tweak Validator
* dataclass and generic tests, docs
* repeat and signature checks
* fix inheritance
* tweaks tests and var names
* improvements to 'from_orm' to work better with root validators (#822)
* improvements to 'from_orm' to work better with root validators
* cython compatibility and tweaks
* tweak config order
* added test for derived classes using custom getter_dict config (#833)
* added test for derived classes using custom getter_dict config
* fix linting
* fix formatting
* cleanup
* Better error for unsuported "typing" objects.
Fixes#745
Add a better error message for fields with types from the typing
module that are not directly supported by Pydantic. Previously,
it caused a cryptic assertion failure.
* Add support for frozenset fields.
Also provide an example of their usage.
Fixes#745
* Address review comments.
Fixes#745
* use equals not "is" for int comparison.
* Update flake8 from 3.6.0 to 3.7.4
* Update mypy from 0.650 to 0.660
* Update pycodestyle from 2.4.0 to 2.5.0
* Update pyflakes from 2.0.0 to 2.1.0
* Update pytest from 4.0.2 to 4.2.0
* Update pytest-cov from 2.6.0 to 2.6.1
* fix test linting
* Properly set Config in create_model
Set the Config attribute in create_model, so it is found by the
MetaModel.
* Black formatting fixes
* Remove uneeded validator logic
* Use single quotes
* Add return value to inherit_validators
* Refactor inherit_validators
* Add HISTORY.rst entry
* Address feedback
* Extend existing validator test cases and remove field aliasing
* Add test cases for validators inherted from parent
* Make test case names consistent with where validators are configured
* Add detail create_model validator inheritance tests
* use type() in int validator to avoid returning a bool since bool is and instance of int
* add note to HISTORY.rst
* add tests & add username and PR # to HISTORY.rst
* use not ininstance(v, bool) to allow int subclassing
* Get rid of `track` in errors
* Move `display_as_type` func into utils module
* Get rid of error as `namedtuple`
* Renamed `Error.index` to `Error.loc`
* New way to get error type
* New way to get error message
* New errors format
* Renamed `flatten_errors` property to `flat_errors`
* `__slots__` for `Error` and `ValidationError`
* `loc` as `tuple`
* Tests
* Review fixes
* `flatten_errors` as generator