- Notifications
You must be signed in to change notification settings - Fork 309
Closed
Labels
Description
Would it be possible to make this warning more specific by mentioning either the value or perhaps the field that caused it?
I am calling request.model_dump_json(indent=2)
and getting
UserWarning: Pydantic serializer warnings: Expected `enum` but got `str` - serialized value may not be as expected return self.__pydantic_serializer__.to_json(
but there so many enum.Enum
in the request
that is hard to find which is causing the warning.
The place where the warning message is composed seems1 to know the value.
fn fallback_warning(&self, field_type: &str, value: &Bound<'_, PyAny>) { if self.mode != WarningsMode::None { let type_name = value .get_type() .qualname() .unwrap_or_else(|_| "<unknown python object>".to_owned()); self.add_warning(format!( "Expected `{field_type}` but got `{type_name}` - serialized value may not be as expected" )); } }
Footnotes
-
I am not sure, since I am not familiar with Rust. ↩
SyntaxColoring and alessio-locatelli