Skip to content

Commit 775bf09

Browse files
committed
lint
1 parent c926b20 commit 775bf09

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

dash/dash.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def _handle_callback_args(args, kwargs):
118118
for arg_or_list in args
119119
# flatten args that are lists
120120
for arg in (
121-
arg_or_list if isinstance(arg_or_list, (list, tuple))
122-
else [arg_or_list]
121+
arg_or_list if isinstance(arg_or_list, (list, tuple)) else [arg_or_list]
123122
)
124123
]
125124
return [
@@ -130,7 +129,7 @@ def _handle_callback_args(args, kwargs):
130129
# keep list of args in order, for matching order
131130
# in the callback's parameters
132131
[arg for arg in args if not isinstance(arg, Output)],
133-
prevent_initial_call
132+
prevent_initial_call,
134133
]
135134

136135

@@ -857,7 +856,9 @@ def interpolate_index(self, **kwargs):
857856
def dependencies(self):
858857
return flask.jsonify(self._callback_list)
859858

860-
def _insert_callback(self, output, inputs, state, callback_args, prevent_initial_call):
859+
def _insert_callback(
860+
self, output, inputs, state, callback_args, prevent_initial_call
861+
):
861862
if prevent_initial_call is None:
862863
prevent_initial_call = self.config.prevent_initial_callbacks
863864

@@ -945,7 +946,13 @@ def clientside_callback(self, clientside_function, *args, **kwargs):
945946
not to fire when its outputs are first added to the page. Defaults to
946947
`False` unless `prevent_initial_callbacks=True` at the app level.
947948
"""
948-
output, inputs, state, callback_args, prevent_initial_call = _handle_callback_args(args, kwargs)
949+
(
950+
output,
951+
inputs,
952+
state,
953+
callback_args,
954+
prevent_initial_call,
955+
) = _handle_callback_args(args, kwargs)
949956
self._insert_callback(output, inputs, state, callback_args)
950957

951958
# If JS source is explicitly given, create a namespace and function
@@ -991,11 +998,17 @@ def callback(self, *args, **kwargs):
991998
"""
992999
# for backward compatibility, store whether first argument is a
9931000
# list of only 1 Output
994-
specified_output_list = (
995-
isinstance(args[0], (list, tuple))
996-
and len(args[0]) == 1)
997-
output, inputs, state, callback_args, prevent_initial_call = _handle_callback_args(args, kwargs)
998-
callback_id = self._insert_callback(output, inputs, state, callback_args, prevent_initial_call)
1001+
specified_output_list = isinstance(args[0], (list, tuple)) and len(args[0]) == 1
1002+
(
1003+
output,
1004+
inputs,
1005+
state,
1006+
callback_args,
1007+
prevent_initial_call,
1008+
) = _handle_callback_args(args, kwargs)
1009+
callback_id = self._insert_callback(
1010+
output, inputs, state, callback_args, prevent_initial_call
1011+
)
9991012

10001013
def wrap_func(func):
10011014
@wraps(func)
@@ -1071,8 +1084,8 @@ def dispatch(self):
10711084
value
10721085
for arg in self.callback_map[output]["args"]
10731086
for value in (inputs + state)
1074-
if arg['id'] == value['id']
1075-
and arg['property'] == value['property']]
1087+
if arg["id"] == value["id"] and arg["property"] == value["property"]
1088+
]
10761089
args = inputs_to_vals(args_inputs)
10771090

10781091
func = self.callback_map[output]["callback"]

tests/integration/test_integration.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -648,16 +648,21 @@ def test_inin019_callback_dep_types():
648648
app = Dash(__name__)
649649
app.layout = html.Div(
650650
[
651-
html.Div("child", id="in1"), html.Div("state", id="state1"), html.Div(id="out1"),
652-
html.Div("child", id="in2"), html.Div("state", id="state2"), html.Div(id="out2"),
653-
html.Div("child", id="in3"), html.Div("state", id="state3"), html.Div(id="out3"),
651+
html.Div("child", id="in1"),
652+
html.Div("state", id="state1"),
653+
html.Div(id="out1"),
654+
html.Div("child", id="in2"),
655+
html.Div("state", id="state2"),
656+
html.Div(id="out2"),
657+
html.Div("child", id="in3"),
658+
html.Div("state", id="state3"),
659+
html.Div(id="out3"),
654660
]
655661
)
656662

657663
with pytest.raises(IncorrectTypeException):
658664

659-
@app.callback([[Output("out1", "children")]],
660-
[Input("in1", "children")])
665+
@app.callback([[Output("out1", "children")]], [Input("in1", "children")])
661666
def f(i):
662667
return i
663668

0 commit comments

Comments
 (0)