-
Notifications
You must be signed in to change notification settings - Fork 266
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
simplify ser-as-any mechanism #1478
base: main
Are you sure you want to change the base?
Conversation
…nix010/pydantic-core into fix-serialize-as-any-with-recursive-ref
Hmm, looks like this needs another pass. Will investigate later. |
CodSpeed Performance ReportMerging #1478 will not alter performanceComparing Summary
|
This now works, and it also fixes the bug, but I'm not sure it's really any simpler. To make things hang together I had to rework all serializer calls inside @sydney-runkle happy to take your call on whether this PR is a good idea. (The |
I think we could probably just do a patch release with that change + this one to make CI happy :). |
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.
This LGTM, definitely feels like a simplification here and is much easier to understand if we just use the boolean pattern 👍
Maybe merging #1480 will give us all we need to measure here. |
Ungh, will investigate the test failures when I get a chance. |
Having just investigated here, my summary is:
So I think we should fix that first, and hopefully can get both of these resolved in v2.11 |
Change Summary
Built atop #1359
The concern I had with that PR is that the "fix" seemed to be a strange special case, which to me implied that there was probably a simplification which would decouple the problem.
Indeed, in this PR I instead propose that when
serialize_as_any=True
then the schema is immediately dropped in favour of anAnySerializer
, and theextra
recordsserialize_as_any
so that if any serializers are re-entered (via inference) then they immediately discard their schema too.Related issue number
Fix pydantic/pydantic#9670
Checklist
pydantic-core
(except for expected changes)