diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a73465b95..ae4c6516dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [UNRELEASED] +### Fixed + +- [#2175](https://github.com/plotly/dash/pull/2175) Fix [#2173](https://github.com/plotly/dash/issues/2173) callback output of ndarray and no_update check. - [#2146](https://github.com/plotly/dash/pull/2146) Remove leftover debug console.log statement. - [#2168](https://github.com/plotly/dash/pull/2168) Reverts [#2126](https://github.com/plotly/dash/pull/2126) (supporting redirect from root when using pages) until the new bugs introduced by that PR are fixed. diff --git a/dash/_callback.py b/dash/_callback.py index 6f48ca63c1..b23f14c6c3 100644 --- a/dash/_callback.py +++ b/dash/_callback.py @@ -40,9 +40,9 @@ def to_plotly_json(self): # pylint: disable=no-self-use @staticmethod def is_no_update(obj): - return isinstance(obj, NoUpdate) or obj == { - "_dash_no_update": "_dash_no_update" - } + return isinstance(obj, NoUpdate) or ( + isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"} + ) GLOBAL_CALLBACK_LIST = [] diff --git a/tests/integration/callbacks/test_basic_callback.py b/tests/integration/callbacks/test_basic_callback.py index bd1cb479bf..709122dc6b 100644 --- a/tests/integration/callbacks/test_basic_callback.py +++ b/tests/integration/callbacks/test_basic_callback.py @@ -4,6 +4,7 @@ import pytest import time +import numpy as np import werkzeug from dash_test_components import ( @@ -765,3 +766,19 @@ def update_output(value): return f"returning {value}" assert update_output("my-value") == "returning my-value" + + +def test_cbsc018_callback_ndarray_output(dash_duo): + app = Dash(__name__) + app.layout = html.Div([dcc.Store(id="output"), html.Button("click", id="clicker")]) + + @app.callback( + Output("output", "data"), + Input("clicker", "n_clicks"), + ) + def on_click(_): + return np.array([[1, 2, 3], [4, 5, 6]], np.int32) + + dash_duo.start_server(app) + + assert dash_duo.get_logs() == []