@@ -946,48 +946,46 @@ def _resolve_value(
946946
947947 if not cls ._required_fields_satisfied (fld , task .definition ):
948948 return None
949- elif isinstance (fld , shell .outarg ) and fld .path_template :
949+ if isinstance (fld , shell .outarg ) and fld .path_template :
950950 return template_update_single (
951951 fld ,
952952 definition = task .definition ,
953953 output_dir = task .output_dir ,
954954 spec_type = "output" ,
955955 )
956- elif fld .callable :
957- callable_ = fld .callable
958- if isinstance (fld .callable , staticmethod ):
959- # In case callable is defined as a static method,
960- # retrieve the function wrapped in the descriptor.
961- callable_ = fld .callable .__func__
962- call_args = inspect .getfullargspec (callable_ )
963- call_args_val = {}
964- for argnm in call_args .args :
965- if argnm == "field" :
966- call_args_val [argnm ] = fld
967- elif argnm == "output_dir" :
968- call_args_val [argnm ] = task .output_dir
969- elif argnm == "inputs" :
970- call_args_val [argnm ] = task .inputs
971- elif argnm == "stdout" :
972- call_args_val [argnm ] = task .return_values ["stdout" ]
973- elif argnm == "stderr" :
974- call_args_val [argnm ] = task .return_values ["stderr" ]
975- else :
976- try :
977- call_args_val [argnm ] = task .inputs [argnm ]
978- except KeyError as e :
979- e .add_note (
980- f"arguments of the callable function from { fld .name } "
981- f"has to be in inputs or be field or output_dir, "
982- f"but { argnm } is used"
983- )
984- raise
985- return callable_ (** call_args_val )
986- else :
987- raise Exception (
988- f"Metadata for '{ fld .name } ', does not not contain any of the required fields "
989- f'("callable", "output_file_template" or "value"): { fld } .'
990- )
956+ assert fld .callable , (
957+ f"Output field '{ fld .name } ', does not not contain any of the required fields "
958+ f'("callable", "output_file_template" or "value"): { fld } .'
959+ )
960+ callable_ = fld .callable
961+ if isinstance (fld .callable , staticmethod ):
962+ # In case callable is defined as a static method,
963+ # retrieve the function wrapped in the descriptor.
964+ callable_ = fld .callable .__func__
965+ call_args = inspect .getfullargspec (callable_ )
966+ call_args_val = {}
967+ for argnm in call_args .args :
968+ if argnm == "field" :
969+ call_args_val [argnm ] = fld
970+ elif argnm == "output_dir" :
971+ call_args_val [argnm ] = task .output_dir
972+ elif argnm == "inputs" :
973+ call_args_val [argnm ] = task .inputs
974+ elif argnm == "stdout" :
975+ call_args_val [argnm ] = task .return_values ["stdout" ]
976+ elif argnm == "stderr" :
977+ call_args_val [argnm ] = task .return_values ["stderr" ]
978+ else :
979+ try :
980+ call_args_val [argnm ] = task .inputs [argnm ]
981+ except KeyError as e :
982+ e .add_note (
983+ f"arguments of the callable function from { fld .name } "
984+ f"has to be in inputs or be field or output_dir, "
985+ f"but { argnm } is used"
986+ )
987+ raise
988+ return callable_ (** call_args_val )
991989
992990
993991ShellOutputsType = ty .TypeVar ("OutputType" , bound = ShellOutputs )
0 commit comments