-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check ModelField().validate_always when inheriting #1545
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1545 +/- ##
===========================================
- Coverage 100.00% 99.94% -0.06%
===========================================
Files 21 21
Lines 3772 3803 +31
Branches 749 756 +7
===========================================
+ Hits 3772 3801 +29
- Misses 0 1 +1
- Partials 0 1 +1
Continue to review full report at Codecov.
|
Please use a descriptive title on the PR. |
This is my first PR. Sorry for the inconvenience I made. And the Change Summary of this PR is the reply to #1155 (comment) |
Looks good, please can you add a change file describing this change. |
fix pydantic#1155 * fix issure pydantic#1155 * add changes.1545-dcHHH.md * improve change description Co-authored-by: dchhh <hudacong@geetest.com> Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* fix issure pydantic#1155 * add changes.1545-dcHHH.md * improve change description Co-authored-by: dchhh <hudacong@geetest.com> Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Change Summary
Indeed, the bug is originated from the change main.py:169. The fields of C is a deepcopy of it's parent class, so C.value_b.validate_always = B.value_b.validate_always = False
https://github.com/samuelcolvin/pydantic/blob/1eeb225c67f1131f948c5f129f5c2e56a4c2c6b7/pydantic/main.py#L881-L883
So value_b is not validated. Just move the assignment of validate_always from self.prepare() to self.populate_validators(), then the bug is solved.
Related issue number
#1155
Checklist
changes/<pull request or issue id>-<github username>.md
file added describing change(see changes/README.md for details)