-
Notifications
You must be signed in to change notification settings - Fork 292
PYD-137: Implement PydanticUseDefault error #714
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
Conversation
please review |
@davidhewitt any idea why the PyPy jobs are failing? It doesn't seem like it's related to this PR |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #714 +/- ##
==========================================
- Coverage 93.71% 93.65% -0.07%
==========================================
Files 99 99
Lines 13838 13864 +26
Branches 25 25
==========================================
+ Hits 12968 12984 +16
- Misses 864 874 +10
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
PYD-137 v1 -> v2 - Getting default value during validation
If you check this example in v1 there was a way to get default value of the in validation function basically the goal is if data that is passed equals to empty string - just change it to default value:
what's the way to get this default value in v2 ? Python, Pydantic & OS Version
Selected Assignee: samuelcolvin |
CodSpeed Performance ReportMerging #714 will degrade performances by 10.88%Comparing Summary
Benchmarks breakdown
|
I haven't reviewed this yet, but my understanding is that the purpose here is to provide a way to escape hatch out of a validator of a field with a default value and pass that default value up the validation chain. I understand that this makes sense in the context of However, I don't think this does a great job of addressing the shortcoming of not having access to Of course, we can try to solve the have-access-to-field-info problem in a different way later on. But my main concern is if this functionality would be rendered unnecessary when we do that, and we end up stuck with the backwards-compatibility maintenance burden. But if we want/need this to get v2 released and @samuelcolvin is okay with it .. then I guess I'm fine with the approach. (I haven't actually read the code yet, just wanted to voice my concern up front.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy to review, code looks good, but my objections to this as a solution still stand. Given how little code there is though, maybe it's not likely to pose a serious maintenance burden
Just to clarify (you mentioned it but maybe it wasn't clear to others) you can already access That is by design. It's unclear what the semantics are for accessing a |
I think this is a good feature either way, it doesn't preclude adding |
Closes pydantic/pydantic#6268
Selected Reviewer: @dmontagu