Skip to content

Commit 105f5a4

Browse files
author
Xing Han Lu
committed
❄️ flake8 + pylint on usage apps
1 parent f7cc272 commit 105f5a4

24 files changed

+60
-72
lines changed

demos/dash_reusable_components.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from textwrap import dedent
2-
31
import dash_core_components as dcc
42
import dash_html_components as html
53

demos/editor/callbacks.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=W0612,R1705
12
import json
23
from colour import Color
34

@@ -28,7 +29,7 @@ def validate_positive(value):
2829
return min(0, value)
2930

3031

31-
def validate_color(color, default='#999999'):
32+
def validate_color(color: str, default='#999999'):
3233
'''
3334
Check if a color is valid, if so returns the color, else return a default color
3435
:param color: The color to validate
@@ -41,10 +42,19 @@ def validate_color(color, default='#999999'):
4142
try:
4243
# Converting 'deep sky blue' to 'deepskyblue'
4344
color = color.replace(" ", "")
45+
46+
if color.startswith('rgb'):
47+
values = color.replace('rgb(', '').replace(')', '').split(',')
48+
49+
if len(values) == 3 and all(0 <= int(v) <= 255 for v in values):
50+
return color
51+
52+
return default
53+
4454
Color(color)
4555
# if everything goes fine then return True
4656
return color
47-
except: # The color code was not found
57+
except: # noqa
4858
return default
4959

5060

@@ -225,7 +235,6 @@ def disable_side_endpoint_width(value):
225235
def disable_side_endpoint_height(value):
226236
return value != 'other'
227237

228-
229238
# ############################## CYTOSCAPE ################################
230239
@app.callback(Output('cytoscape', 'elements'),
231240
[Input('dropdown-select-element-list', 'value')])

demos/editor/layout.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@
437437
id='dropdown-edge-curve-style',
438438
value='haystack',
439439
clearable=False,
440-
searchable=False,
441440
options=drc.DropdownOptionsList(
442441
'haystack',
443442
'bezier',
@@ -610,8 +609,7 @@
610609
placeholder='Input value in % or px...',
611610
value='0px'
612611
)
613-
]) for side in
614-
['source', 'target']],
612+
]) for side in ['source', 'target']],
615613

616614
drc.NamedInput(
617615
name='Source Distance from node',
@@ -637,8 +635,7 @@
637635
drc.NamedRadioItems(
638636
name='Use Labels',
639637
id='radio-use-labels',
640-
options=drc.DropdownOptionsList('yes',
641-
'no'),
638+
options=drc.DropdownOptionsList('yes', 'no'),
642639
value='no'
643640
),
644641

@@ -682,8 +679,7 @@
682679
options=[{
683680
'label': element.capitalize(),
684681
'value': f'div-label-{element}'
685-
} for element in
686-
LABEL_ELEMENT_TYPES],
682+
} for element in LABEL_ELEMENT_TYPES],
687683
clearable=False,
688684
value='div-label-node'
689685
),
@@ -760,8 +756,7 @@
760756
searchable=False,
761757
value='none'
762758
)
763-
]) for element in
764-
LABEL_ELEMENT_TYPES],
759+
]) for element in LABEL_ELEMENT_TYPES],
765760
]),
766761
drc.NamedCard(title='Text Wrapping', size=4, children=[
767762
drc.NamedDropdown(
@@ -770,8 +765,7 @@
770765
options=[{
771766
'label': element.capitalize(),
772767
'value': f'div-text-wrapping-{element}'
773-
} for element in
774-
LABEL_ELEMENT_TYPES],
768+
} for element in LABEL_ELEMENT_TYPES],
775769
clearable=False,
776770
value='div-text-wrapping-node'
777771
),
@@ -796,8 +790,7 @@
796790
type='number',
797791
placeholder='Enter the maximum width in px...'
798792
)
799-
]) for element in
800-
LABEL_ELEMENT_TYPES],
793+
]) for element in LABEL_ELEMENT_TYPES],
801794
]),
802795
drc.NamedCard(title='Label Alignment', size=4, children=[
803796
drc.NamedRadioItems(
@@ -848,23 +841,24 @@
848841
value='div-text-margins-node'
849842
),
850843

851-
*[html.Div(id=f'div-text-margins-{element}',
852-
children=[
853-
drc.NamedInput(
854-
name=f"{element.capitalize()} Margin X (px)",
855-
id=f'input-{element}-text-margin-x',
856-
type='number',
857-
placeholder='Enter a value in px...'
858-
),
859-
860-
drc.NamedInput(
861-
name=f"{element.capitalize()} Margin Y(px)",
862-
id=f'input-{element}-text-margin-y',
863-
type='number',
864-
placeholder='Enter a value in px...'
865-
)
866-
]) for element in
867-
LABEL_ELEMENT_TYPES_ALL],
844+
*[html.Div(
845+
id=f'div-text-margins-{element}',
846+
children=[
847+
drc.NamedInput(
848+
name=f"{element.capitalize()} Margin X (px)",
849+
id=f'input-{element}-text-margin-x',
850+
type='number',
851+
placeholder='Enter a value in px...'
852+
),
853+
854+
drc.NamedInput(
855+
name=f"{element.capitalize()} Margin Y(px)",
856+
id=f'input-{element}-text-margin-y',
857+
type='number',
858+
placeholder='Enter a value in px...'
859+
)
860+
]
861+
) for element in LABEL_ELEMENT_TYPES_ALL],
868862
])
869863
]
870864
)

demos/usage-animated-bfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/animated-bfs/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/animated-bfs
3+
Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/animated-bfs
44
55
Note: Animation Not Implemented yet, please refer to code.
66
"""

demos/usage-breadthfirst-layout.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/images-breadthfirst-layout/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/images-breadthfirst-layout
43
54
Note: Click Animation is not implemented.
65
"""

demos/usage-circle-layout.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/circle-layout/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/circle-layout
43
"""
54
import json
65

demos/usage-compound-nodes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/compound-nodes/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/compound-nodes
43
54
Note: The Dash version is also uncentered. Otherwise it works.
65
"""

demos/usage-concentric-layout.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/concentric-layout/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/blob/master/documentation/demos/concentric-layout/code.js
43
54
Note: This example is broken because layout takes a function as input, i.e.
65
```

demos/usage-concentric-social-network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@
7070

7171

7272
if __name__ == '__main__':
73-
app.run_server(debug=True)
73+
app.run_server(debug=True)

demos/usage-cose-bilkent-layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
22
Original Demo: http://js.cytoscape.org/demos/cose-bilkent-layout-compound/
3-
Original Code: https://github.com/cytoscape/cytoscape.js/tree/master/documentation/demos/cose-bilkent-layout-compound
43
54
Note: This implementation DOES NOT work yet, since cose-bilkent hasn't been implemented yet
65
@@ -16,7 +15,8 @@
1615
server = app.server
1716

1817
app.scripts.append_script({
19-
'external_url': 'https://cdn.rawgit.com/cytoscape/cytoscape.js-cose-bilkent/d810281d/cytoscape-cose-bilkent.js'
18+
'external_url': ('https://cdn.rawgit.com/cytoscape/cytoscape.js-cose-bilkent/d810281d/'
19+
'cytoscape-cose-bilkent.js')
2020
})
2121

2222
app.scripts.config.serve_locally = True

0 commit comments

Comments
 (0)