Skip to content

Commit d677428

Browse files
authored
Add quotes to field name in serialization warning (#1816)
1 parent 7a1a124 commit d677428

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/serializers/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl PydanticSerializationUnexpectedValue {
195195
if let Some(field_name) = &self.field_name {
196196
write!(
197197
message,
198-
" [field_name={field_name}, input_value={value_str}, input_type={input_type}]"
198+
" [field_name='{field_name}', input_value={value_str}, input_type={input_type}]"
199199
)
200200
.expect("writing to string should never fail");
201201
} else {

tests/serializers/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_model_wrong_warn():
286286

287287
with pytest.warns(
288288
UserWarning,
289-
match=r"Expected `int` - serialized value may not be as expected \[field_name=foo, input_value='lorem', input_type=str\]",
289+
match=r"Expected `int` - serialized value may not be as expected \[field_name='foo', input_value='lorem', input_type=str\]",
290290
):
291291
assert s.to_python(BasicModel(foo='lorem')) == {'foo': 'lorem'}
292292

0 commit comments

Comments
 (0)