-
Notifications
You must be signed in to change notification settings - Fork 309
Match return type of SerializationInfo.mode() to mode of model_dump() #1770
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
Pydantic sometimes uses Literal['python', 'json'] | str for the serialization mode. Using a more restrictive type can cause issues (e.g., typing validation errors). This commit adjusts the return type to align with other valid Pydantic serialization modes and prevent such issues. This can be seen as a follow-up to commit: 9b239c1
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
a87f8c5
to
075cbcf
Compare
CodSpeed Performance ReportMerging #1770 will not alter performanceComparing Summary
|
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 indeed matches the behaviour and type hints elsewhere, thanks.
Should have marked the PR as blocked as I was waiting for an answer in #1747 (comment). I'll revert and change other places where |
…l_dump() (#1770)" This reverts commit d0dbb09. See #1747 (comment) for more details.
…pydantic/pydantic-core#1770) Co-authored-by: Julian Vanden Broeck <[email protected]> Original-commit-hash: d0dbb09
…l_dump() (pydantic/pydantic-core#1770)" (pydantic/pydantic-core#1797) Original-commit-hash: 25b0649
…el_dump() (pydantic/pydantic-core#1770)" (pydantic/pydantic-core#1797) (pydantic/pydantic-core#1815) Original-commit-hash: 7a1a124
Change Summary
Pydantic in some place use
Literal['python', 'json'] | str
for the serialization mode, using a more restrictive type can break stuff (e.g. typing validation). So this commit adapt the return type to make it matches with other pydantic valid serialization mode.Related issue number
Checklist
pydantic-core
(except for expected changes)