@@ -183,7 +183,7 @@ def extract_function_inputs_and_outputs(
183
183
input_types [p .name ] = type_hints .get (p .name , ty .Any )
184
184
if p .default is not inspect .Parameter .empty :
185
185
input_defaults [p .name ] = p .default
186
- if inputs :
186
+ if inputs is not None :
187
187
if not isinstance (inputs , dict ):
188
188
raise ValueError (
189
189
f"Input names ({ inputs } ) should not be provided when "
@@ -218,45 +218,46 @@ def extract_function_inputs_and_outputs(
218
218
f"value { default } "
219
219
)
220
220
return_type = type_hints .get ("return" , ty .Any )
221
- if outputs and len (outputs ) > 1 :
222
- if return_type is not ty .Any :
223
- if ty .get_origin (return_type ) is not tuple :
224
- raise ValueError (
225
- f"Multiple outputs specified ({ outputs } ) but non-tuple "
226
- f"return value { return_type } "
227
- )
228
- return_types = ty .get_args (return_type )
229
- if len (return_types ) != len (outputs ):
230
- raise ValueError (
231
- f"Length of the outputs ({ outputs } ) does not match that "
232
- f"of the return types ({ return_types } )"
233
- )
234
- output_types = dict (zip (outputs , return_types ))
235
- else :
236
- output_types = {o : ty .Any for o in outputs }
237
- if isinstance (outputs , dict ):
238
- for output_name , output in outputs .items ():
239
- if isinstance (output , Out ) and output .type is ty .Any :
240
- output .type = output_types [output_name ]
221
+ if outputs :
222
+ if len (outputs ) > 1 :
223
+ if return_type is not ty .Any :
224
+ if ty .get_origin (return_type ) is not tuple :
225
+ raise ValueError (
226
+ f"Multiple outputs specified ({ outputs } ) but non-tuple "
227
+ f"return value { return_type } "
228
+ )
229
+ return_types = ty .get_args (return_type )
230
+ if len (return_types ) != len (outputs ):
231
+ raise ValueError (
232
+ f"Length of the outputs ({ outputs } ) does not match that "
233
+ f"of the return types ({ return_types } )"
234
+ )
235
+ output_types = dict (zip (outputs , return_types ))
236
+ else :
237
+ output_types = {o : ty .Any for o in outputs }
238
+ if isinstance (outputs , dict ):
239
+ for output_name , output in outputs .items ():
240
+ if isinstance (output , Out ) and output .type is ty .Any :
241
+ output .type = output_types [output_name ]
242
+ else :
243
+ outputs = output_types
241
244
else :
242
- outputs = output_types
243
-
244
- elif outputs :
245
- if isinstance (outputs , dict ):
246
- output_name , output = next (iter (outputs .items ()))
247
- elif isinstance (outputs , list ):
248
- output_name = outputs [0 ]
249
- output = ty .Any
250
- if isinstance (output , Out ):
251
- if output .type is ty .Any :
252
- output .type = return_type
253
- elif output is ty .Any :
254
- output = return_type
255
- outputs = {output_name : output }
256
- elif return_type is not None :
257
- outputs = {"out" : return_type }
245
+ if isinstance (outputs , dict ):
246
+ output_name , output = next (iter (outputs .items ()))
247
+ elif isinstance (outputs , list ):
248
+ output_name = outputs [0 ]
249
+ output = ty .Any
250
+ if isinstance (output , Out ):
251
+ if output .type is ty .Any :
252
+ output .type = return_type
253
+ elif output is ty .Any :
254
+ output = return_type
255
+ outputs = {output_name : output }
258
256
else :
259
- outputs = {}
257
+ if return_type not in (None , type (None )):
258
+ outputs = {"out" : return_type }
259
+ else :
260
+ outputs = {}
260
261
return inputs , outputs
261
262
262
263
0 commit comments