From aaa6c2d98c9641ad6e6b477e33cbd04e67afbdbc Mon Sep 17 00:00:00 2001 From: NotSomeBot <43829743+mariusdkm@users.noreply.github.com> Date: Sun, 16 Apr 2023 18:06:35 +0200 Subject: [PATCH 1/3] Fix: Error message --- dash/_validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dash/_validate.py b/dash/_validate.py index d1b94a284f..20381dccfa 100644 --- a/dash/_validate.py +++ b/dash/_validate.py @@ -201,7 +201,7 @@ def validate_multi_return(outputs_list, output_value, callback_id): dedent( f""" Invalid number of output values for {callback_id} item {i}. - Expected {len(vi)}, got {len(outi)} + Expected {len(outi)}, got {len(vi)} output spec: {outi!r} output value: {vi!r} """ From 8e89bc3d1f48e6c819b4d534ab0fd6bd9427803d Mon Sep 17 00:00:00 2001 From: mariusdkm Date: Thu, 20 Apr 2023 17:36:33 +0200 Subject: [PATCH 2/3] Chore: rename variables --- dash/_validate.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dash/_validate.py b/dash/_validate.py index 20381dccfa..5b1cdd0548 100644 --- a/dash/_validate.py +++ b/dash/_validate.py @@ -161,49 +161,49 @@ def validate_and_group_input_args(flat_args, arg_index_grouping): return func_args, func_kwargs -def validate_multi_return(outputs_list, output_value, callback_id): - if not isinstance(output_value, (list, tuple)): +def validate_multi_return(output_lists, output_values, callback_id): + if not isinstance(output_values, (list, tuple)): raise exceptions.InvalidCallbackReturnValue( dedent( f""" The callback {callback_id} is a multi-output. Expected the output type to be a list or tuple but got: - {output_value!r}. + {output_values!r}. """ ) ) - if len(output_value) != len(outputs_list): + if len(output_values) != len(output_lists): raise exceptions.InvalidCallbackReturnValue( f""" Invalid number of output values for {callback_id}. - Expected {len(outputs_list)}, got {len(output_value)} + Expected {len(output_lists)}, got {len(output_values)} """ ) - for i, outi in enumerate(outputs_list): - if isinstance(outi, list): - vi = output_value[i] - if not isinstance(vi, (list, tuple)): + for i, output_spec in enumerate(output_lists): + if isinstance(output_spec, list): + output_value = output_values[i] + if not isinstance(output_value, (list, tuple)): raise exceptions.InvalidCallbackReturnValue( dedent( f""" The callback {callback_id} output {i} is a wildcard multi-output. Expected the output type to be a list or tuple but got: - {vi!r}. - output spec: {outi!r} + {output_value!r}. + output spec: {output_spec!r} """ ) ) - if len(vi) != len(outi): + if len(output_value) != len(output_spec): raise exceptions.InvalidCallbackReturnValue( dedent( f""" Invalid number of output values for {callback_id} item {i}. - Expected {len(outi)}, got {len(vi)} - output spec: {outi!r} - output value: {vi!r} + Expected {len(output_spec)}, got {len(output_value)} + output spec: {output_spec!r} + output value: {output_value!r} """ ) ) From 555e60fac9a973a207813ae15b4891c927b51af1 Mon Sep 17 00:00:00 2001 From: mariusdkm Date: Thu, 20 Apr 2023 17:37:57 +0200 Subject: [PATCH 3/3] Add: changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8955cef5a8..4600b8a068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to `dash` will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). +## [UNRELEASED] + +## Fixed + +- [#2508](https://github.com/plotly/dash/pull/2508) Fix error message, when callback output has different length than spec + ## [2.9.3] - 2023-04-13 ## Fixed