Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoUpdate is a Valid Prop #3127

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
9 changes: 9 additions & 0 deletions dash/_no_update.py
Original file line number Diff line number Diff line change
@@ -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"}
)
5 changes: 3 additions & 2 deletions dash/_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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__
Expand Down