Skip to content

Commit 3ef7086

Browse files
committed
don't show Undefined in default factory error
1 parent f481aa6 commit 3ef7086

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/errors/validation_exception.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ impl PyLineError {
528528
};
529529
write!(output, " {message} [type={}", self.error_type.type_string())?;
530530

531-
if !hide_input {
531+
// special case: don't show input for DefaultFactoryNotCalled errors - there is no valid input
532+
if !hide_input && !matches!(self.error_type, ErrorType::DefaultFactoryNotCalled { .. }) {
532533
let input_value = self.input_value.bind(py);
533534
let input_str = safe_repr(input_value);
534535
write!(output, ", input_value=")?;

tests/validators/test_with_default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,6 @@ def __init__(self, a: int, b: int):
873873
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='not_an_int', input_type=str]
874874
For further information visit https://errors.pydantic.dev/{pydantic_version}/v/int_parsing
875875
b
876-
The default factory uses validated data, but at least one validation error occurred [type=default_factory_not_called, input_value=PydanticUndefined, input_type=PydanticUndefinedType]
876+
The default factory uses validated data, but at least one validation error occurred [type=default_factory_not_called]
877877
For further information visit https://errors.pydantic.dev/{pydantic_version}/v/default_factory_not_called"""
878878
)

0 commit comments

Comments
 (0)