Skip to content

Commit 62db98a

Browse files
authored
Merge pull request #3127 from 2Ryan09/no-update-is-valid-prop
`NoUpdate` is a Valid Prop
2 parents 35d817b + 5f12f0b commit 62db98a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

dash/_callback.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from . import _validate
4343
from .background_callback.managers import BaseBackgroundCallbackManager
4444
from ._callback_context import context_value
45+
from ._no_update import NoUpdate
4546

4647

4748
async def _async_invoke_callback(
@@ -58,17 +59,6 @@ def _invoke_callback(func, *args, **kwargs): # used to mark the frame for the d
5859
return func(*args, **kwargs) # %% callback invoked %%
5960

6061

61-
class NoUpdate:
62-
def to_plotly_json(self): # pylint: disable=no-self-use
63-
return {"_dash_no_update": "_dash_no_update"}
64-
65-
@staticmethod
66-
def is_no_update(obj):
67-
return isinstance(obj, NoUpdate) or (
68-
isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"}
69-
)
70-
71-
7262
GLOBAL_CALLBACK_LIST = []
7363
GLOBAL_CALLBACK_MAP = {}
7464
GLOBAL_INLINE_SCRIPTS = []

dash/_no_update.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class NoUpdate:
2+
def to_plotly_json(self): # pylint: disable=no-self-use
3+
return {"_dash_no_update": "_dash_no_update"}
4+
5+
@staticmethod
6+
def is_no_update(obj):
7+
return isinstance(obj, NoUpdate) or (
8+
isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"}
9+
)

dash/_validate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import flask
77

88
from ._grouping import grouping_len, map_grouping
9+
from ._no_update import NoUpdate
910
from .development.base_component import Component
1011
from . import exceptions
1112
from ._utils import (
@@ -211,8 +212,8 @@ def validate_multi_return(output_lists, output_values, callback_id):
211212

212213

213214
def fail_callback_output(output_value, output):
214-
valid_children = (str, int, float, type(None), Component)
215-
valid_props = (str, int, float, type(None), tuple, MutableSequence)
215+
valid_children = (str, int, float, type(None), Component, NoUpdate)
216+
valid_props = (str, int, float, type(None), tuple, MutableSequence, NoUpdate)
216217

217218
def _raise_invalid(bad_val, outer_val, path, index=None, toplevel=False):
218219
bad_type = type(bad_val).__name__

0 commit comments

Comments
 (0)