Skip to content

Commit 075cbcf

Browse files
author
Julian Vanden Broeck
committed
Match return type of SerializationInfo.mode() to mode of model_dump()
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
1 parent 04b296b commit 075cbcf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/pydantic_core/core_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def context(self) -> ContextT:
145145
...
146146

147147
@property
148-
def mode(self) -> Literal['python', 'json']:
148+
def mode(self) -> Literal['python', 'json'] | str:
149149
"""The serialization mode set during serialization."""
150150
...
151151

0 commit comments

Comments
 (0)