@@ -113,9 +113,7 @@ impl UnionValidator {
113113 let strict = state. strict_or ( self . strict ) ;
114114 let mut errors = MaybeErrors :: new ( self . custom_error . as_ref ( ) ) ;
115115
116- // we use this to track the validation against the most compatible union member
117- // up to the current point
118- let mut success: Option < ( Py < PyAny > , Exactness , Option < usize > ) > = None ;
116+ let mut best_match: Option < ( Py < PyAny > , Exactness , Option < usize > ) > = None ;
119117
120118 for ( choice, label) in & self . choices {
121119 let state = & mut state. rebind_extra ( |extra| {
@@ -151,7 +149,7 @@ impl UnionValidator {
151149 // if the fields_set_count is not available for either the current best match or the new candidate,
152150 // we use the exactness to determine the best match.
153151 let new_success_is_best_match: bool =
154- success
152+ best_match
155153 . as_ref ( )
156154 . map_or ( true , |( _, cur_exactness, cur_fields_set_count) | {
157155 match ( * cur_fields_set_count, new_fields_set_count) {
@@ -161,13 +159,13 @@ impl UnionValidator {
161159 } ) ;
162160
163161 if new_success_is_best_match {
164- success = Some ( ( new_success, new_exactness, new_fields_set_count) ) ;
162+ best_match = Some ( ( new_success, new_exactness, new_fields_set_count) ) ;
165163 }
166164 }
167165 } ,
168166 Err ( ValError :: LineErrors ( lines) ) => {
169167 // if we don't yet know this validation will succeed, record the error
170- if success . is_none ( ) {
168+ if best_match . is_none ( ) {
171169 errors. push ( choice, label. as_deref ( ) , lines) ;
172170 }
173171 }
@@ -179,12 +177,12 @@ impl UnionValidator {
179177 state. exactness = old_exactness;
180178 state. fields_set_count = old_fields_set_count;
181179
182- if let Some ( ( success , exactness, fields_set_count) ) = success {
180+ if let Some ( ( best_match , exactness, fields_set_count) ) = best_match {
183181 state. floor_exactness ( exactness) ;
184182 if let Some ( count) = fields_set_count {
185183 state. add_fields_set ( count) ;
186184 }
187- return Ok ( success ) ;
185+ return Ok ( best_match ) ;
188186 }
189187
190188 // no matches, build errors
0 commit comments