@@ -915,6 +915,11 @@ def clientside_callback(self, clientside_function, *args):
915
915
}
916
916
917
917
def callback (self , * args ):
918
+ # for backward compatibility, store whether first argument is a
919
+ # list of only 1 Output
920
+ specified_output_list = (
921
+ isinstance (args [0 ], (list , tuple ))
922
+ and len (args [0 ]) == 1 )
918
923
output , inputs , state , callback_args = _handle_callback_args (* args )
919
924
callback_id = self ._insert_callback (output , inputs , state , callback_args )
920
925
@@ -931,11 +936,8 @@ def add_context(*args, **kwargs):
931
936
932
937
# wrap single outputs so we can treat them all the same
933
938
# for validation and response creation
934
- if not isinstance (output_value , (list , tuple )):
935
- if not isinstance (output_spec , (list , tuple )):
936
- output_value , output_spec = [output_value ], [output_spec ]
937
- else :
938
- output_value , output_spec = [output_value ], output_spec
939
+ if len (output_spec ) == 1 and not specified_output_list :
940
+ output_value = [output_value ]
939
941
940
942
_validate .validate_multi_return (output_spec , output_value , callback_id )
941
943
0 commit comments