Skip to content

Commit e7b9d5e

Browse files
committed
Fix linting
1 parent 72b796d commit e7b9d5e

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

dash/dash.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,27 @@ class _NoUpdate(object):
9898
"""
9999

100100

101+
def _handle_callback_args(*args):
102+
"""Split args into outputs, inputs and states"""
103+
args = [
104+
arg
105+
# for backward compatibility, one arg can be a list
106+
for arg_or_list in args
107+
# flatten args that are lists
108+
for arg in (
109+
arg_or_list if isinstance(arg_or_list, (list, tuple))
110+
else [arg_or_list])
111+
]
112+
return [
113+
# split according to type Output, Input, State
114+
[arg for arg in args if isinstance(arg, class_)]
115+
for class_ in [Output, Input, State]
116+
] + [
117+
# keep list of args in order, for matching order
118+
# in the callback's parameters
119+
[arg for arg in args if not isinstance(arg, Output)]]
120+
121+
101122
# pylint: disable=too-many-instance-attributes
102123
# pylint: disable=too-many-arguments, too-many-locals
103124
class Dash(object):
@@ -861,7 +882,7 @@ def clientside_callback(self, clientside_function, *args):
861882
)
862883
```
863884
"""
864-
output, inputs, state, callback_args = self._handle_callback_args(*args)
885+
output, inputs, state, callback_args = _handle_callback_args(*args)
865886
self._insert_callback(output, inputs, state, callback_args)
866887

867888
# If JS source is explicitly given, create a namespace and function
@@ -893,28 +914,8 @@ def clientside_callback(self, clientside_function, *args):
893914
"function_name": function_name,
894915
}
895916

896-
def _handle_callback_args(self, *args):
897-
"""Split args into outputs, inputs and states"""
898-
args = [
899-
arg
900-
# for backward compatibility, one arg can be a list
901-
for arg_or_list in args
902-
# flatten args that are lists
903-
for arg in (
904-
arg_or_list if isinstance(arg_or_list, (list, tuple))
905-
else [arg_or_list])
906-
]
907-
return [
908-
# split according to type Output, Input, State
909-
[arg for arg in args if isinstance(arg, class_)]
910-
for class_ in [Output, Input, State]
911-
] + [
912-
# keep list of args in order, for matching order
913-
# in the callback's parameters
914-
[arg for arg in args if not isinstance(arg, Output)]]
915-
916917
def callback(self, *args):
917-
output, inputs, state, callback_args = self._handle_callback_args(*args)
918+
output, inputs, state, callback_args = _handle_callback_args(*args)
918919
callback_id = self._insert_callback(output, inputs, state, callback_args)
919920

920921
def wrap_func(func):

tests/integration/test_integration.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,10 @@ def update_output(value):
647647
def test_inin019_callback_dep_types():
648648
app = Dash(__name__)
649649
app.layout = html.Div(
650-
[html.Div("child", id="in1"), html.Div("state", id="state1"), html.Div(id="out1"),
651-
html.Div("child", id="in2"), html.Div("state", id="state2"), html.Div(id="out2"),
652-
html.Div("child", id="in3"), html.Div("state", id="state3"), html.Div(id="out3"),
650+
[
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"),
653654
]
654655
)
655656

0 commit comments

Comments
 (0)