diff --git a/dash/_callback.py b/dash/_callback.py index 071c209dec..0ed452d773 100644 --- a/dash/_callback.py +++ b/dash/_callback.py @@ -37,23 +37,13 @@ from . import _validate from .long_callback.managers import BaseLongCallbackManager from ._callback_context import context_value +from ._no_update import NoUpdate def _invoke_callback(func, *args, **kwargs): # used to mark the frame for the debugger return func(*args, **kwargs) # %% callback invoked %% -class NoUpdate: - def to_plotly_json(self): # pylint: disable=no-self-use - return {"_dash_no_update": "_dash_no_update"} - - @staticmethod - def is_no_update(obj): - return isinstance(obj, NoUpdate) or ( - isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"} - ) - - GLOBAL_CALLBACK_LIST = [] GLOBAL_CALLBACK_MAP = {} GLOBAL_INLINE_SCRIPTS = [] diff --git a/dash/_no_update.py b/dash/_no_update.py new file mode 100644 index 0000000000..b86004de72 --- /dev/null +++ b/dash/_no_update.py @@ -0,0 +1,9 @@ +class NoUpdate: + def to_plotly_json(self): # pylint: disable=no-self-use + return {"_dash_no_update": "_dash_no_update"} + + @staticmethod + def is_no_update(obj): + return isinstance(obj, NoUpdate) or ( + isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"} + ) diff --git a/dash/_validate.py b/dash/_validate.py index a26fd0f73b..7d32fbb5bd 100644 --- a/dash/_validate.py +++ b/dash/_validate.py @@ -6,6 +6,7 @@ import flask from ._grouping import grouping_len, map_grouping +from ._no_update import NoUpdate from .development.base_component import Component from . import exceptions from ._utils import ( @@ -211,8 +212,8 @@ def validate_multi_return(output_lists, output_values, callback_id): def fail_callback_output(output_value, output): - valid_children = (str, int, float, type(None), Component) - valid_props = (str, int, float, type(None), tuple, MutableSequence) + valid_children = (str, int, float, type(None), Component, NoUpdate) + valid_props = (str, int, float, type(None), tuple, MutableSequence, NoUpdate) def _raise_invalid(bad_val, outer_val, path, index=None, toplevel=False): bad_type = type(bad_val).__name__