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

expose NoUpdate #2800

Open
wants to merge 4 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
2 changes: 1 addition & 1 deletion dash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from . import dash_table # noqa: F401,E402
from .version import __version__ # noqa: F401,E402
from ._callback_context import callback_context # noqa: F401,E402
from ._callback import callback, clientside_callback # noqa: F401,E402
from ._callback import callback, clientside_callback, NoUpdateType # noqa: F401,E402
from ._get_app import get_app # noqa: F401,E402
from ._get_paths import ( # noqa: F401,E402
get_asset_url,
Expand Down
14 changes: 7 additions & 7 deletions dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def _invoke_callback(func, *args, **kwargs): # used to mark the frame for the d
return func(*args, **kwargs) # %% callback invoked %%


class NoUpdate:
class NoUpdateType:
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 (
return isinstance(obj, NoUpdateType) or (
isinstance(obj, dict) and obj == {"_dash_no_update": "_dash_no_update"}
)

Expand Down Expand Up @@ -423,7 +423,7 @@ def add_context(*args, **kwargs):
job_running = callback_manager.job_running(job_id)
if not job_running and output_value is callback_manager.UNDEFINED:
# Job canceled -> no output to close the loop.
output_value = NoUpdate()
output_value = NoUpdateType()

elif (
isinstance(output_value, dict)
Expand All @@ -440,7 +440,7 @@ def add_context(*args, **kwargs):

if multi and isinstance(output_value, (list, tuple)):
output_value = [
NoUpdate() if NoUpdate.is_no_update(r) else r
NoUpdateType() if NoUpdateType.is_no_update(r) else r
for r in output_value
]

Expand All @@ -449,7 +449,7 @@ def add_context(*args, **kwargs):
else:
output_value = _invoke_callback(func, *func_args, **func_kwargs)

if NoUpdate.is_no_update(output_value):
if NoUpdateType.is_no_update(output_value):
raise PreventUpdate

if not multi:
Expand All @@ -471,12 +471,12 @@ def add_context(*args, **kwargs):
component_ids = collections.defaultdict(dict)
has_update = False
for val, spec in zip(flat_output_values, output_spec):
if isinstance(val, NoUpdate):
if isinstance(val, NoUpdateType):
continue
for vali, speci in (
zip(val, spec) if isinstance(spec, list) else [[val, spec]]
):
if not isinstance(vali, NoUpdate):
if not isinstance(vali, NoUpdateType):
has_update = True
id_str = stringify_id(speci["id"])
prop = clean_property_name(speci["property"])
Expand Down
2 changes: 1 addition & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _do_skip(error):


# Singleton signal to not update an output, alternative to PreventUpdate
no_update = _callback.NoUpdate() # pylint: disable=protected-access
no_update = _callback.NoUpdateType() # pylint: disable=protected-access


# pylint: disable=too-many-instance-attributes
Expand Down
2 changes: 1 addition & 1 deletion dash/long_callback/managers/celery_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def run():
else:
user_callback_output = fn(*maybe_progress, user_callback_args)
except PreventUpdate:
# Put NoUpdate dict directly to avoid circular imports.
# Put NoUpdateType dict directly to avoid circular imports.
cache.set(
result_key,
json.dumps(
Expand Down