Skip to content

Commit 1321683

Browse files
committed
fixing for lint
1 parent 6445159 commit 1321683

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

dash/dash-renderer/src/actions/callbacks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function unwrapIfNotMulti(
123123
if (idProps.length !== 1) {
124124
if (!idProps.length) {
125125
if (spec.allow_optional) {
126-
idProps = [{...spec, value: null}]
127-
msg = ''
126+
idProps = [{...spec, value: null}];
127+
msg = '';
128128
} else {
129129
const isStr = typeof spec.id === 'string';
130130
msg =

dash/dependencies.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def component_id_str(self) -> str:
5959

6060
def to_dict(self) -> dict:
6161
specs = {"id": self.component_id_str(), "property": self.component_property}
62-
return {**specs, 'allow_optional': True} if self.allow_optional else specs
62+
return {**specs, "allow_optional": True} if self.allow_optional else specs
6363

6464
def __eq__(self, other):
6565
"""
@@ -136,6 +136,7 @@ def __init__(
136136

137137
class Input(DashDependency): # pylint: disable=too-few-public-methods
138138
"""Input of callback: trigger an update when it is updated."""
139+
139140
def __init__(
140141
self,
141142
component_id: ComponentIdType,
@@ -149,6 +150,7 @@ def __init__(
149150

150151
class State(DashDependency): # pylint: disable=too-few-public-methods
151152
"""Use the value of a State in a callback but don't trigger updates."""
153+
152154
def __init__(
153155
self,
154156
component_id: ComponentIdType,
@@ -158,6 +160,7 @@ def __init__(
158160
super().__init__(component_id, component_property)
159161
self.allow_optional = allow_optional
160162
self.allowed_wildcards = (MATCH, ALL, ALLSMALLER)
163+
161164
# allowed_wildcards = (MATCH, ALL, ALLSMALLER)
162165

163166

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
from dash import *
22

3+
34
def test_cbop001_optional_input(dash_duo):
45
app = Dash(suppress_callback_exceptions=True)
56

67
app.layout = html.Div(
78
[
8-
html.Button(id='button1', children='Button 1'),
9-
html.Div(id='button-container'),
10-
html.Div(id='test-out'),
11-
html.Div(id='test-out2')
9+
html.Button(id="button1", children="Button 1"),
10+
html.Div(id="button-container"),
11+
html.Div(id="test-out"),
12+
html.Div(id="test-out2"),
1213
]
1314
)
1415

1516
@app.callback(
16-
Output('button-container', 'children'),
17-
Input('button1', 'n_clicks'),
18-
State('button-container', 'children'),
19-
prevent_initial_call=True
17+
Output("button-container", "children"),
18+
Input("button1", "n_clicks"),
19+
State("button-container", "children"),
20+
prevent_initial_call=True,
2021
)
2122
def _(_, c):
2223
if not c:
23-
return html.Button(id='button2', children='Button 2')
24+
return html.Button(id="button2", children="Button 2")
2425
return no_update
2526

2627
@app.callback(
27-
Output('test-out', 'children'),
28-
Input('button1', 'n_clicks'),
29-
Input('button2', 'n_clicks', allow_optional=True),
30-
prevent_inital_call=True
28+
Output("test-out", "children"),
29+
Input("button1", "n_clicks"),
30+
Input("button2", "n_clicks", allow_optional=True),
31+
prevent_inital_call=True,
3132
)
3233
def display(n, n2):
3334
return f"{n} - {n2}"
3435

3536
dash_duo.start_server(app)
36-
dash_duo.wait_for_text_to_equal('#button1', 'Button 1')
37+
dash_duo.wait_for_text_to_equal("#button1", "Button 1")
3738
assert dash_duo.get_logs() == []
38-
dash_duo.wait_for_text_to_equal('#test-out', 'None - None')
39+
dash_duo.wait_for_text_to_equal("#test-out", "None - None")
3940
dash_duo.find_element("#button1").click()
40-
dash_duo.wait_for_text_to_equal('#test-out', '1 - None')
41+
dash_duo.wait_for_text_to_equal("#test-out", "1 - None")
4142

4243
dash_duo.find_element("#button2").click()
43-
dash_duo.wait_for_text_to_equal('#test-out', '1 - 1')
44+
dash_duo.wait_for_text_to_equal("#test-out", "1 - 1")
4445
assert dash_duo.get_logs() == []
4546

4647

47-
4848
def test_cbop002_optional_state(dash_duo):
4949
app = Dash(suppress_callback_exceptions=True)
5050

5151
app.layout = html.Div(
5252
[
53-
html.Button(id='button1', children='Button 1'),
54-
html.Div(id='button-container'),
55-
html.Div(id='test-out'),
56-
html.Div(id='test-out2')
53+
html.Button(id="button1", children="Button 1"),
54+
html.Div(id="button-container"),
55+
html.Div(id="test-out"),
56+
html.Div(id="test-out2"),
5757
]
5858
)
5959

6060
@app.callback(
61-
Output('button-container', 'children'),
62-
Input('button1', 'n_clicks'),
63-
State('button-container', 'children'),
64-
prevent_initial_call=True
61+
Output("button-container", "children"),
62+
Input("button1", "n_clicks"),
63+
State("button-container", "children"),
64+
prevent_initial_call=True,
6565
)
6666
def _(_, c):
6767
if not c:
68-
return html.Button(id='button2', children='Button 2')
68+
return html.Button(id="button2", children="Button 2")
6969
return no_update
7070

7171
@app.callback(
72-
Output('test-out', 'children'),
73-
Input('button1', 'n_clicks'),
74-
State('button2', 'n_clicks', allow_optional=True),
75-
prevent_inital_call=True
72+
Output("test-out", "children"),
73+
Input("button1", "n_clicks"),
74+
State("button2", "n_clicks", allow_optional=True),
75+
prevent_inital_call=True,
7676
)
7777
def display(n, n2):
7878
return f"{n} - {n2}"
7979

8080
@app.callback(
81-
Output('test-out2', 'children'),
82-
Input('button2', 'n_clicks', allow_optional=True)
81+
Output("test-out2", "children"),
82+
Input("button2", "n_clicks", allow_optional=True),
8383
)
8484
def test(n):
8585
if n:
8686
return n
8787
return no_update
8888

8989
dash_duo.start_server(app)
90-
dash_duo.wait_for_text_to_equal('#button1', 'Button 1')
90+
dash_duo.wait_for_text_to_equal("#button1", "Button 1")
9191
assert dash_duo.get_logs() == []
92-
dash_duo.wait_for_text_to_equal('#test-out', 'None - None')
92+
dash_duo.wait_for_text_to_equal("#test-out", "None - None")
9393
dash_duo.find_element("#button1").click()
94-
dash_duo.wait_for_text_to_equal('#test-out', '1 - None')
94+
dash_duo.wait_for_text_to_equal("#test-out", "1 - None")
9595

9696
dash_duo.find_element("#button2").click()
97-
dash_duo.wait_for_text_to_equal('#test-out2', '1')
98-
dash_duo.wait_for_text_to_equal('#test-out', '1 - None')
97+
dash_duo.wait_for_text_to_equal("#test-out2", "1")
98+
dash_duo.wait_for_text_to_equal("#test-out", "1 - None")
9999
dash_duo.find_element("#button1").click()
100-
dash_duo.wait_for_text_to_equal('#test-out', '2 - 1')
100+
dash_duo.wait_for_text_to_equal("#test-out", "2 - 1")
101101
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)