Skip to content

Commit 5d492dc

Browse files
committed
fixing issue with indentations of layouts
1 parent e24e094 commit 5d492dc

File tree

2 files changed

+65
-60
lines changed

2 files changed

+65
-60
lines changed

dash/_callback.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def callback(
8080
manager=None,
8181
cache_args_to_ignore=None,
8282
on_error: Optional[Callable[[Exception], Any]] = None,
83+
use_async=False,
8384
**_kwargs,
8485
):
8586
"""
@@ -154,6 +155,8 @@ def callback(
154155
Function to call when the callback raises an exception. Receives the
155156
exception object as first argument. The callback_context can be used
156157
to access the original callback inputs, states and output.
158+
:param use_async:
159+
Tells the system to await for this async callback.
157160
"""
158161

159162
long_spec = None
@@ -204,6 +207,7 @@ def callback(
204207
manager=manager,
205208
running=running,
206209
on_error=on_error,
210+
use_async=use_async
207211
)
208212

209213

@@ -324,7 +328,7 @@ def register_callback(
324328
manager = _kwargs.get("manager")
325329
running = _kwargs.get("running")
326330
on_error = _kwargs.get("on_error")
327-
use_async = _kwargs.get("app_use_async")
331+
use_async = _kwargs.get("use_async")
328332
if running is not None:
329333
if not isinstance(running[0], (list, tuple)):
330334
running = [running]

dash/dash.py

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,7 @@ def router():
23572357
Output(_ID_STORE, "data"),
23582358
inputs=inputs,
23592359
prevent_initial_call=True,
2360+
use_async=True
23602361
)
23612362
async def update(pathname_, search_, **states):
23622363
"""
@@ -2383,37 +2384,37 @@ async def update(pathname_, search_, **states):
23832384
layout = page.get("layout", "")
23842385
title = page["title"]
23852386

2386-
if callable(layout):
2387-
layout = await execute_async_function(layout,
2388-
**{**(path_variables or {}), **query_parameters, **states}
2389-
)
2390-
if callable(title):
2391-
title = await execute_async_function(title,
2392-
**(path_variables or {})
2393-
)
2394-
2395-
return layout, {"title": title}
2396-
2397-
_validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY)
2398-
_validate.validate_registry(_pages.PAGE_REGISTRY)
2399-
2400-
# Set validation_layout
2401-
if not self.config.suppress_callback_exceptions:
2402-
self.validation_layout = html.Div(
2403-
[
2404-
asyncio.run(execute_async_function(page["layout"])) if callable(page["layout"]) else page[
2405-
"layout"]
2406-
for page in _pages.PAGE_REGISTRY.values()
2407-
]
2408-
+ [
2409-
# pylint: disable=not-callable
2410-
self.layout()
2411-
if callable(self.layout)
2412-
else self.layout
2387+
if callable(layout):
2388+
layout = await execute_async_function(layout,
2389+
**{**(path_variables or {}), **query_parameters, **states}
2390+
)
2391+
if callable(title):
2392+
title = await execute_async_function(title,
2393+
**(path_variables or {})
2394+
)
2395+
2396+
return layout, {"title": title}
2397+
2398+
_validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY)
2399+
_validate.validate_registry(_pages.PAGE_REGISTRY)
2400+
2401+
# Set validation_layout
2402+
if not self.config.suppress_callback_exceptions:
2403+
self.validation_layout = html.Div(
2404+
[
2405+
asyncio.run(execute_async_function(page["layout"])) if callable(page["layout"]) else page[
2406+
"layout"]
2407+
for page in _pages.PAGE_REGISTRY.values()
24132408
]
2414-
)
2415-
if _ID_CONTENT not in self.validation_layout:
2416-
raise Exception("`dash.page_container` not found in the layout")
2409+
+ [
2410+
# pylint: disable=not-callable
2411+
self.layout()
2412+
if callable(self.layout)
2413+
else self.layout
2414+
]
2415+
)
2416+
if _ID_CONTENT not in self.validation_layout:
2417+
raise Exception("`dash.page_container` not found in the layout")
24172418
else:
24182419
@self.callback(
24192420
Output(_ID_CONTENT, "children"),
@@ -2446,35 +2447,35 @@ def update(pathname_, search_, **states):
24462447
layout = page.get("layout", "")
24472448
title = page["title"]
24482449

2449-
if callable(layout):
2450-
layout = layout(**{**(path_variables or {}), **query_parameters,
2451-
**states})
2452-
if callable(title):
2453-
title = title(**(path_variables or {}))
2454-
2455-
return layout, {"title": title}
2456-
2457-
_validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY)
2458-
_validate.validate_registry(_pages.PAGE_REGISTRY)
2459-
2460-
# Set validation_layout
2461-
if not self.config.suppress_callback_exceptions:
2462-
self.validation_layout = html.Div(
2463-
[
2464-
page["layout"]() if callable(page["layout"]) else
2465-
page[
2466-
"layout"]
2467-
for page in _pages.PAGE_REGISTRY.values()
2468-
]
2469-
+ [
2470-
# pylint: disable=not-callable
2471-
self.layout()
2472-
if callable(self.layout)
2473-
else self.layout
2474-
]
2475-
)
2476-
if _ID_CONTENT not in self.validation_layout:
2477-
raise Exception("`dash.page_container` not found in the layout")
2450+
if callable(layout):
2451+
layout = layout(**{**(path_variables or {}), **query_parameters,
2452+
**states})
2453+
if callable(title):
2454+
title = title(**(path_variables or {}))
2455+
2456+
return layout, {"title": title}
2457+
2458+
_validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY)
2459+
_validate.validate_registry(_pages.PAGE_REGISTRY)
2460+
2461+
# Set validation_layout
2462+
if not self.config.suppress_callback_exceptions:
2463+
self.validation_layout = html.Div(
2464+
[
2465+
page["layout"]() if callable(page["layout"]) else
2466+
page[
2467+
"layout"]
2468+
for page in _pages.PAGE_REGISTRY.values()
2469+
]
2470+
+ [
2471+
# pylint: disable=not-callable
2472+
self.layout()
2473+
if callable(self.layout)
2474+
else self.layout
2475+
]
2476+
)
2477+
if _ID_CONTENT not in self.validation_layout:
2478+
raise Exception("`dash.page_container` not found in the layout")
24782479

24792480
# Update the page title on page navigation
24802481
self.clientside_callback(

0 commit comments

Comments
 (0)