@@ -32,21 +32,16 @@ pub struct ValidationError {
32
32
line_errors : Vec < PyLineError > ,
33
33
error_mode : ErrorMode ,
34
34
title : PyObject ,
35
- hide_input_in_errors : bool ,
35
+ hide_input : bool ,
36
36
}
37
37
38
38
impl ValidationError {
39
- pub fn new (
40
- line_errors : Vec < PyLineError > ,
41
- title : PyObject ,
42
- error_mode : ErrorMode ,
43
- hide_input_in_errors : bool ,
44
- ) -> Self {
39
+ pub fn new ( line_errors : Vec < PyLineError > , title : PyObject , error_mode : ErrorMode , hide_input : bool ) -> Self {
45
40
Self {
46
41
line_errors,
47
42
title,
48
43
error_mode,
49
- hide_input_in_errors ,
44
+ hide_input ,
50
45
}
51
46
}
52
47
@@ -56,7 +51,7 @@ impl ValidationError {
56
51
error_mode : ErrorMode ,
57
52
error : ValError ,
58
53
outer_location : Option < LocItem > ,
59
- hide_input_in_errors : bool ,
54
+ hide_input : bool ,
60
55
) -> PyErr {
61
56
match error {
62
57
ValError :: LineErrors ( raw_errors) => {
@@ -67,7 +62,7 @@ impl ValidationError {
67
62
. collect ( ) ,
68
63
None => raw_errors. into_iter ( ) . map ( |e| e. into_py ( py) ) . collect ( ) ,
69
64
} ;
70
- let validation_error = Self :: new ( line_errors, title, error_mode, hide_input_in_errors ) ;
65
+ let validation_error = Self :: new ( line_errors, title, error_mode, hide_input ) ;
71
66
match Py :: new ( py, validation_error) {
72
67
Ok ( err) => PyErr :: from_value ( err. into_ref ( py) ) ,
73
68
Err ( err) => err,
@@ -78,15 +73,9 @@ impl ValidationError {
78
73
}
79
74
}
80
75
81
- pub fn display ( & self , py : Python , prefix_override : Option < & ' static str > , hide_input_in_errors : bool ) -> String {
76
+ pub fn display ( & self , py : Python , prefix_override : Option < & ' static str > , hide_input : bool ) -> String {
82
77
let url_prefix = get_url_prefix ( py, include_url_env ( py) ) ;
83
- let line_errors = pretty_py_line_errors (
84
- py,
85
- & self . error_mode ,
86
- self . line_errors . iter ( ) ,
87
- url_prefix,
88
- hide_input_in_errors,
89
- ) ;
78
+ let line_errors = pretty_py_line_errors ( py, & self . error_mode , self . line_errors . iter ( ) , url_prefix, hide_input) ;
90
79
if let Some ( prefix) = prefix_override {
91
80
format ! ( "{prefix}\n {line_errors}" )
92
81
} else {
@@ -139,21 +128,21 @@ impl<'a> IntoPy<ValError<'a>> for ValidationError {
139
128
#[ pymethods]
140
129
impl ValidationError {
141
130
#[ staticmethod]
142
- #[ pyo3( signature = ( title, line_errors, error_mode=None , hide_input_in_errors =false ) ) ]
131
+ #[ pyo3( signature = ( title, line_errors, error_mode=None , hide_input =false ) ) ]
143
132
fn from_exception_data (
144
133
py : Python ,
145
134
title : PyObject ,
146
135
line_errors : & PyList ,
147
136
error_mode : Option < & str > ,
148
- hide_input_in_errors : bool ,
137
+ hide_input : bool ,
149
138
) -> PyResult < Py < Self > > {
150
139
Py :: new (
151
140
py,
152
141
Self {
153
142
line_errors : line_errors. iter ( ) . map ( PyLineError :: try_from) . collect :: < PyResult < _ > > ( ) ?,
154
143
title,
155
144
error_mode : ErrorMode :: try_from ( error_mode) ?,
156
- hide_input_in_errors ,
145
+ hide_input ,
157
146
} ,
158
147
)
159
148
}
@@ -228,7 +217,7 @@ impl ValidationError {
228
217
}
229
218
230
219
fn __repr__ ( & self , py : Python ) -> String {
231
- self . display ( py, None , self . hide_input_in_errors )
220
+ self . display ( py, None , self . hide_input )
232
221
}
233
222
234
223
fn __str__ ( & self , py : Python ) -> String {
@@ -256,10 +245,10 @@ pub fn pretty_py_line_errors<'a>(
256
245
error_mode : & ErrorMode ,
257
246
line_errors_iter : impl Iterator < Item = & ' a PyLineError > ,
258
247
url_prefix : Option < & str > ,
259
- hide_input_in_errors : bool ,
248
+ hide_input : bool ,
260
249
) -> String {
261
250
line_errors_iter
262
- . map ( |i| i. pretty ( py, error_mode, url_prefix, hide_input_in_errors ) )
251
+ . map ( |i| i. pretty ( py, error_mode, url_prefix, hide_input ) )
263
252
. collect :: < Result < Vec < _ > , _ > > ( )
264
253
. unwrap_or_else ( |err| vec ! [ format!( "[error formatting line errors: {err}]" ) ] )
265
254
. join ( "\n " )
@@ -373,7 +362,7 @@ impl PyLineError {
373
362
py : Python ,
374
363
error_mode : & ErrorMode ,
375
364
url_prefix : Option < & str > ,
376
- hide_input_in_errors : bool ,
365
+ hide_input : bool ,
377
366
) -> Result < String , fmt:: Error > {
378
367
let mut output = String :: with_capacity ( 200 ) ;
379
368
write ! ( output, "{}" , self . location) ?;
@@ -384,7 +373,7 @@ impl PyLineError {
384
373
} ;
385
374
write ! ( output, " {message} [type={}" , self . error_type. type_string( ) ) ?;
386
375
387
- if !hide_input_in_errors {
376
+ if !hide_input {
388
377
let input_value = self . input_value . as_ref ( py) ;
389
378
let input_str = safe_repr ( input_value) ;
390
379
truncate_input_value ! ( output, input_str) ;
0 commit comments