Skip to content

Commit 567d0f8

Browse files
committed
fixing formatting
1 parent c4795ed commit 567d0f8

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

dash/backends/_fastapi.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_current_request() -> Request:
5252
class CurrentRequestMiddleware:
5353
def __init__(self, app: ASGIApp) -> None: # type: ignore[name-defined]
5454
self.app = app
55-
print('loaded CurrentRequestMiddleware')
55+
print("loaded CurrentRequestMiddleware")
5656

5757
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: # type: ignore[name-defined]
5858
# non-http/ws scopes pass through (lifespan etc.)
@@ -84,7 +84,6 @@ def load_config():
8484

8585

8686
class FastAPIDashServer(BaseDashServer):
87-
8887
def __init__(self, server: FastAPI):
8988
self.config = {}
9089
self.server_type = "fastapi"
@@ -415,7 +414,6 @@ async def serve(request: Request, package_name: str, fingerprinted_path: str):
415414

416415
# pylint: disable=unused-argument
417416
def dispatch(self, dash_app: Dash):
418-
419417
async def _dispatch(request: Request):
420418
# pylint: disable=protected-access
421419
body = await request.json()
@@ -470,7 +468,9 @@ async def timing_middleware(request: Request, call_next):
470468
headers.append("Server-Timing", value)
471469
return response
472470

473-
def register_callback_api_routes(self, callback_api_paths: Dict[str, Callable[..., Any]]):
471+
def register_callback_api_routes(
472+
self, callback_api_paths: Dict[str, Callable[..., Any]]
473+
):
474474
"""
475475
Register callback API endpoints on the FastAPI app.
476476
Each key in callback_api_paths is a route, each value is a handler (sync or async).
@@ -504,7 +504,6 @@ async def view_func(request: Request, body: dict = Body(...)):
504504

505505

506506
class FastAPIRequestAdapter(RequestAdapter):
507-
508507
def __init__(self):
509508
self._request: Request = get_current_request()
510509
super().__init__()

dash/backends/_flask.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030

3131
class FlaskDashServer(BaseDashServer):
32-
3332
def __init__(self, server: Flask) -> None:
3433
self.server: Flask = server
3534
self.server_type = "flask"
@@ -209,7 +208,9 @@ def _dispatch():
209208
func = dash_app._prepare_callback(cb_ctx, body)
210209
args = dash_app._inputs_to_vals(cb_ctx.inputs_list + cb_ctx.states_list)
211210
ctx = copy_context()
212-
partial_func = dash_app._execute_callback(func, args, cb_ctx.outputs_list, cb_ctx)
211+
partial_func = dash_app._execute_callback(
212+
func, args, cb_ctx.outputs_list, cb_ctx
213+
)
213214
response_data = ctx.run(partial_func)
214215
if asyncio.iscoroutine(response_data):
215216
raise Exception(
@@ -227,7 +228,9 @@ async def _dispatch_async():
227228
func = dash_app._prepare_callback(cb_ctx, body)
228229
args = dash_app._inputs_to_vals(cb_ctx.inputs_list + cb_ctx.states_list)
229230
ctx = copy_context()
230-
partial_func = dash_app._execute_callback(func, args, cb_ctx.outputs_list, cb_ctx)
231+
partial_func = dash_app._execute_callback(
232+
func, args, cb_ctx.outputs_list, cb_ctx
233+
)
231234
response_data = ctx.run(partial_func)
232235
if asyncio.iscoroutine(response_data):
233236
response_data = await response_data
@@ -269,7 +272,9 @@ def _after_request(response: Response): # type: ignore[name-defined]
269272
self.before_request(_before_request)
270273
self.after_request(_after_request)
271274

272-
def register_callback_api_routes(self, callback_api_paths: Dict[str, Callable[..., Any]]):
275+
def register_callback_api_routes(
276+
self, callback_api_paths: Dict[str, Callable[..., Any]]
277+
):
273278
"""
274279
Register callback API endpoints on the Flask app.
275280
Each key in callback_api_paths is a route, each value is a handler (sync or async).

dash/backends/_quart.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030

3131
class QuartDashServer(BaseDashServer):
32-
3332
def __init__(self, server: Quart) -> None:
3433
self.server_type = "quart"
3534
self.server: Quart = server
@@ -41,7 +40,9 @@ def __call__(self, *args: Any, **kwargs: Any): # type: ignore[name-defined]
4140
return self.server(*args, **kwargs)
4241

4342
@staticmethod
44-
def create_app(name: str = "__main__", config: _t.Optional[_t.Dict[str, _t.Any]] = None):
43+
def create_app(
44+
name: str = "__main__", config: _t.Optional[_t.Dict[str, _t.Any]] = None
45+
):
4546
if Quart is None:
4647
raise RuntimeError(
4748
"Quart is not installed. Install with 'pip install quart' to use the quart backend."
@@ -225,7 +226,6 @@ async def _invalid_resource(err):
225226
return err.args[0], 404
226227

227228
def _html_response_wrapper(self, view_func: _t.Callable[..., _t.Any] | str):
228-
229229
async def wrapped(*_args, **_kwargs):
230230
html_val = view_func() if callable(view_func) else view_func
231231
if inspect.iscoroutine(html_val): # handle async function returning html
@@ -247,15 +247,13 @@ def add_url_rule(
247247
)
248248

249249
def setup_index(self, dash_app: Dash): # type: ignore[name-defined]
250-
251250
async def index(*args, **kwargs):
252251
return Response(dash_app.index(*args, **kwargs), content_type="text/html") # type: ignore[arg-type]
253252

254253
# pylint: disable=protected-access
255254
dash_app._add_url("", index, methods=["GET"])
256255

257256
def setup_catchall(self, dash_app: Dash):
258-
259257
async def catchall(
260258
path: str, *args, **kwargs
261259
): # noqa: ARG001 - path is unused but kept for route signature, pylint: disable=unused-argument
@@ -331,7 +329,6 @@ async def serve(package_name, fingerprinted_path):
331329

332330
# pylint: disable=unused-argument
333331
def dispatch(self, dash_app: Dash): # type: ignore[name-defined] Quart always async
334-
335332
async def _dispatch():
336333
adapter = QuartRequestAdapter()
337334
body = await adapter.get_json()
@@ -351,7 +348,9 @@ async def _dispatch():
351348

352349
return _dispatch
353350

354-
def register_callback_api_routes(self, callback_api_paths: _t.Dict[str, _t.Callable[..., _t.Any]]):
351+
def register_callback_api_routes(
352+
self, callback_api_paths: _t.Dict[str, _t.Callable[..., _t.Any]]
353+
):
355354
"""
356355
Register callback API endpoints on the Quart app.
357356
Each key in callback_api_paths is a route, each value is a handler (sync or async).

0 commit comments

Comments
 (0)