You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
fnfallback_warning(&self,field_type:&str,value:&Bound<'_,PyAny>){ifself.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. ↩
The text was updated successfully, but these errors were encountered:
By the way, I was able to find the value and field causing the warning by building pydantic-core with the following modification to the error message
- "Expected `{field_type}` but got `{type_name}` - serialized value may not be as expected"
+ "Expected `{field_type}` but got `{type_name}` value: `{value}` - serialized value may not be as expected"
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 gettingbut there so many
enum.Enum
in therequest
that is hard to find which is causing the warning.The place where the warning message is composed seems1 to know the value.
Footnotes
I am not sure, since I am not familiar with Rust. ↩
The text was updated successfully, but these errors were encountered: