Skip to content

Commit c926b20

Browse files
wilhelmhbalexcjohnson
authored andcommitted
Fix backward compatibility for single output lists
1 parent b61e4d0 commit c926b20

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dash/dash.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ def callback(self, *args, **kwargs):
989989
not to fire when its outputs are first added to the page. Defaults to
990990
`False` unless `prevent_initial_callbacks=True` at the app level.
991991
"""
992+
# for backward compatibility, store whether first argument is a
993+
# list of only 1 Output
994+
specified_output_list = (
995+
isinstance(args[0], (list, tuple))
996+
and len(args[0]) == 1)
992997
output, inputs, state, callback_args, prevent_initial_call = _handle_callback_args(args, kwargs)
993998
callback_id = self._insert_callback(output, inputs, state, callback_args, prevent_initial_call)
994999

@@ -1005,11 +1010,8 @@ def add_context(*args, **kwargs):
10051010

10061011
# wrap single outputs so we can treat them all the same
10071012
# for validation and response creation
1008-
if not isinstance(output_value, (list, tuple)):
1009-
if not isinstance(output_spec, (list, tuple)):
1010-
output_value, output_spec = [output_value], [output_spec]
1011-
else:
1012-
output_value, output_spec = [output_value], output_spec
1013+
if len(output_spec) == 1 and not specified_output_list:
1014+
output_value = [output_value]
10131015

10141016
_validate.validate_multi_return(output_spec, output_value, callback_id)
10151017

0 commit comments

Comments
 (0)