Skip to content

Commit 0aa9e6f

Browse files
committed
Refactor hide_all_callbacks as paramater of run()
1 parent d91d715 commit 0aa9e6f

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

dash/dash.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,6 @@ class Dash(ObsoleteChecker):
367367
those callbacks you wish to have an initial call. This setting has no
368368
effect on triggering callbacks when their inputs change later on.
369369
370-
:param hide_all_callbacks: Default ``False``: Sets the default value of
371-
``hidden`` for all callbacks added to the app. Normally all callbacks
372-
are visible in the devtools callbacks tab. You can set this for
373-
individual callbacks by setting ``hidden`` in their definitions, or set
374-
it ``True`` here in which case you must explicitly set it ``False`` for
375-
those callbacks you wish to remain visible in the devtools callbacks tab.
376-
377370
:param show_undo_redo: Default ``False``, set to ``True`` to enable undo
378371
and redo buttons for stepping through the history of the app state.
379372
:type show_undo_redo: boolean
@@ -464,7 +457,6 @@ def __init__( # pylint: disable=too-many-statements
464457
external_stylesheets: Optional[Sequence[Union[str, Dict[str, Any]]]] = None,
465458
suppress_callback_exceptions: Optional[bool] = None,
466459
prevent_initial_callbacks: bool = False,
467-
hide_all_callbacks: bool = False,
468460
show_undo_redo: bool = False,
469461
extra_hot_reload_paths: Optional[Sequence[str]] = None,
470462
plugins: Optional[list] = None,
@@ -545,14 +537,14 @@ def __init__( # pylint: disable=too-many-statements
545537
"suppress_callback_exceptions", suppress_callback_exceptions, False
546538
),
547539
prevent_initial_callbacks=prevent_initial_callbacks,
548-
hide_all_callbacks=hide_all_callbacks,
549540
show_undo_redo=show_undo_redo,
550541
extra_hot_reload_paths=extra_hot_reload_paths or [],
551542
title=title,
552543
update_title=update_title,
553544
include_pages_meta=include_pages_meta,
554545
description=description,
555546
health_endpoint=health_endpoint,
547+
hide_all_callbacks=False,
556548
)
557549
self.config.set_read_only(
558550
[
@@ -1655,14 +1647,16 @@ def _setup_server(self):
16551647
self.callback_map[k] = _callback.GLOBAL_CALLBACK_MAP.pop(k)
16561648

16571649
self._callback_list.extend(_callback.GLOBAL_CALLBACK_LIST)
1650+
16581651
# For each callback function, if the hidden parameter uses the default value None,
1659-
# replace it with the actual value of the hide_all_callbacks property of the current application instance.
1652+
# replace it with the actual value of the self.config.hide_all_callbacks.
16601653
self._callback_list = [
16611654
{**_callback, "hidden": self.config.get("hide_all_callbacks", False)}
16621655
if _callback.get("hidden") is None
16631656
else _callback
16641657
for _callback in self._callback_list
16651658
]
1659+
16661660
_callback.GLOBAL_CALLBACK_LIST.clear()
16671661

16681662
_validate.validate_background_callbacks(self.callback_map)
@@ -2310,6 +2304,7 @@ def run(
23102304
port: Optional[Union[str, int]] = None,
23112305
proxy: Optional[str] = None,
23122306
debug: Optional[bool] = None,
2307+
hide_all_callbacks: bool = False,
23132308
jupyter_mode: Optional[JupyterDisplayMode] = None,
23142309
jupyter_width: str = "100%",
23152310
jupyter_height: int = 650,
@@ -2358,6 +2353,14 @@ def run(
23582353
via ``run``. env: ``DASH_DEBUG``
23592354
:type debug: bool
23602355
2356+
:param hide_all_callbacks: Default ``False``: Sets the default value of
2357+
``hidden`` for all callbacks added to the app. Normally all callbacks
2358+
are visible in the devtools callbacks tab. You can set this for
2359+
individual callbacks by setting ``hidden`` in their definitions, or set
2360+
it ``True`` here in which case you must explicitly set it ``False`` for
2361+
those callbacks you wish to remain visible in the devtools callbacks tab.
2362+
:type hide_all_callbacks: bool
2363+
23612364
:param dev_tools_ui: Show the dev tools UI. env: ``DASH_UI``
23622365
:type dev_tools_ui: bool
23632366
@@ -2424,6 +2427,10 @@ def run(
24242427
24252428
:return:
24262429
"""
2430+
2431+
# Update self.config.hide_all_callbacks
2432+
self.config.update({'hide_all_callbacks': hide_all_callbacks})
2433+
24272434
if debug is None:
24282435
debug = get_combined_config("debug", None, False)
24292436

0 commit comments

Comments
 (0)