Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

l00ptr
Copy link

@l00ptr l00ptr commented Jul 30, 2025

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

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

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
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@l00ptr l00ptr force-pushed the fix-return-type-for-mode branch from a87f8c5 to 075cbcf Compare July 30, 2025 14:06
Copy link

codspeed-hq bot commented Jul 30, 2025

CodSpeed Performance Report

Merging #1770 will not alter performance

Comparing l00ptr:fix-return-type-for-mode (075cbcf) with main (04b296b)

Summary

✅ 157 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant