@@ -10,7 +10,9 @@ use pyo3::IntoPyObjectExt;
1010use crate :: build_tools:: py_schema_err;
1111use crate :: build_tools:: { schema_or_config_same, ExtraBehavior } ;
1212use crate :: errors:: { ErrorTypeDefaults , ValError , ValLineError , ValResult } ;
13- use crate :: input:: { Arguments , BorrowInput , Input , KeywordArgs , PositionalArgs , ValidatedDict , ValidationMatch } ;
13+ use crate :: input:: {
14+ Arguments , BorrowInput , Input , KeywordArgs , PositionalArgs , ValidatedDict , ValidatedTuple , ValidationMatch ,
15+ } ;
1416use crate :: lookup_key:: LookupKey ;
1517use crate :: tools:: SchemaDict ;
1618
@@ -209,11 +211,29 @@ impl ArgumentsV3Validator {
209211 Err ( err) => return Err ( err) ,
210212 }
211213 }
212- // ParameterMode::VarArgs => match dict_value.validate_tuple() {
213- // Ok(iterable) => for value in iterable,
214- // Err(err) => return Err(err),
215- // },
216- ParameterMode :: VarArgs => todo ! ( ) ,
214+ ParameterMode :: VarArgs => match dict_value. borrow_input ( ) . validate_tuple ( false ) {
215+ Ok ( tuple) => {
216+ tuple. unpack ( state) . try_for_each ( |v| {
217+ match parameter. validator . validate ( py, v. unwrap ( ) . borrow_input ( ) , state) {
218+ Ok ( tuple_value) => {
219+ output_args. push ( tuple_value) ;
220+ return Ok ( ( ) ) ;
221+ }
222+ Err ( ValError :: LineErrors ( line_errors) ) => {
223+ errors. extend ( line_errors. into_iter ( ) . map ( |err| {
224+ lookup_path. apply_error_loc ( err, self . loc_by_alias , & parameter. name )
225+ } ) ) ;
226+ return Ok ( ( ) ) ;
227+ }
228+ Err ( err) => return Err ( err) ,
229+ }
230+ } ) ?;
231+ }
232+ Err ( _) => {
233+ let val_error = ValLineError :: new ( ErrorTypeDefaults :: TupleType , dict_value. borrow_input ( ) ) ;
234+ errors. push ( lookup_path. apply_error_loc ( val_error, self . loc_by_alias , & parameter. name ) ) ;
235+ }
236+ } ,
217237 ParameterMode :: KeywordOnly => {
218238 match parameter. validator . validate ( py, dict_value. borrow_input ( ) , state) {
219239 Ok ( value) => {
@@ -240,6 +260,7 @@ impl ArgumentsV3Validator {
240260 for err in line_errors {
241261 errors. push (
242262 err. with_outer_location ( dict_key. clone ( ) )
263+ . with_outer_location ( & parameter. name )
243264 . with_type ( ErrorTypeDefaults :: InvalidKey ) ,
244265 ) ;
245266 }
@@ -252,14 +273,21 @@ impl ArgumentsV3Validator {
252273 Ok ( value) => output_kwargs. set_item ( dict_key, value) ?,
253274 Err ( ValError :: LineErrors ( line_errors) ) => {
254275 errors. extend ( line_errors. into_iter ( ) . map ( |err| {
255- lookup_path. apply_error_loc ( err, self . loc_by_alias , & parameter. name )
276+ lookup_path. apply_error_loc (
277+ err. with_outer_location ( dict_key. clone ( ) ) ,
278+ self . loc_by_alias ,
279+ & parameter. name ,
280+ )
256281 } ) ) ;
257282 }
258283 Err ( err) => return Err ( err) ,
259284 }
260285 }
261286 }
262- None => todo ! ( ) ,
287+ None => {
288+ let val_error = ValLineError :: new ( ErrorTypeDefaults :: DictType , dict_value) ;
289+ errors. push ( lookup_path. apply_error_loc ( val_error, self . loc_by_alias , & parameter. name ) ) ;
290+ }
263291 } ,
264292 ParameterMode :: VarKwargsUnpackedTypedDict => {
265293 let kwargs_dict = dict_value
0 commit comments