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
Validator ignoring 'always=True' on optional fields on inheritance #1155
Comments
Thanks for reporting, I get the same. The intermediate model The problem is b521f6b and almost certainly the change It might be as simple as reversing that change, but I made it for a reason (that currently escapes me). I'll look at it next week or when I get a chance, if it's urgent feel free to investigate and submit a PR if you can find a fix. |
* fix issure #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 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>
Fixed by #1545 |
Possible Bug
Validator seems to ignore the 'always' parameter on inheritance since pydantic >= 1.2
I had a running code that uses inheritance on the models with an enforced field that is used to decide if other optional fields will be checked, or not. This worked well until I updated to pydantic 1.3. Further testing shows that the code fails since pydantic 1.2. So there seem to be some changes from 1.1 to 1.2 that leads to this issue.
Unfortunately I could not find a previous issue, or documentation hint that explains this deviating behavior to me.
If I missed something in the doc, please give me a hint and excuse my issue. Otherwise, I would be thankful if someone could fix this, or explain how the intended behavior can be achieved on pydantic >=1.2
Please find an example code and corresponding output below.
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Here is an example code to reproduce this issue and below that, the corresponding output on pydantic 1.1 and >=1.2:
Output on pydantic 1.1 (This is the intended behavior!)
Output on pydantic >=1.2
The text was updated successfully, but these errors were encountered: