Skip to content

Commit bc78cfc

Browse files
committed
👕 include flake8 so that build would fail if coding style is not good though the unit passed
1 parent 00ddc4e commit bc78cfc

14 files changed

Lines changed: 47 additions & 35 deletions

File tree

pyecharts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/usr/bin/env python
21
# coding=utf-8
2+
# flake8: noqa
33

44
from pyecharts._version import __version__, __author__
55

pyecharts/base.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ def cast(seq):
103103
""" 转换数据序列,将带字典和元组类型的序列转换为 k_lst,v_lst 两个列表
104104
105105
元组列表
106-
[(A1, B1), (A2, B2), ...] --> k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
106+
[(A1, B1), (A2, B2), ...] -->
107+
k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
107108
字典列表
108-
[{A1: B1}, {A2: B2}, ...] --> k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
109+
[{A1: B1}, {A2: B2}, ...] -->
110+
k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
109111
字典
110-
{A1: B1, A2: B2, ...} -- > k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
112+
{A1: B1, A2: B2, ...} -- >
113+
k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]
111114
112115
:param seq:
113116
待转换的序列
@@ -116,17 +119,14 @@ def cast(seq):
116119
k_lst, v_lst = [], []
117120
if isinstance(seq, list):
118121
for s in seq:
119-
try:
120-
if isinstance(s, tuple):
121-
_attr, _value = s
122-
k_lst.append(_attr)
123-
v_lst.append(_value)
124-
elif isinstance(s, dict):
125-
for k, v in s.items():
126-
k_lst.append(k)
127-
v_lst.append(v)
128-
except:
129-
raise
122+
if isinstance(s, tuple):
123+
_attr, _value = s
124+
k_lst.append(_attr)
125+
v_lst.append(_value)
126+
elif isinstance(s, dict):
127+
for k, v in s.items():
128+
k_lst.append(k)
129+
v_lst.append(v)
130130
elif isinstance(seq, dict):
131131
for k, v in seq.items():
132132
k_lst.append(k)
@@ -178,10 +178,10 @@ def default(self, obj):
178178
else:
179179
try:
180180
return obj.astype(float).tolist()
181-
except:
181+
except Exception:
182182
try:
183183
return obj.astype(str).tolist()
184-
except:
184+
except Exception:
185185
return json.JSONEncoder.default(self, obj)
186186

187187

pyecharts/charts/bar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def __add(self, name, x_axis, y_axis,
3838
kwargs.update(x_axis=x_axis)
3939
chart = get_all_options(**kwargs)
4040

41-
is_stack = "stack_" + str(self._option['series_id']) if is_stack else ""
41+
if is_stack:
42+
is_stack = "stack_" + str(self._option['series_id'])
43+
else:
44+
is_stack = ""
4245
xaxis, yaxis = chart['xy_axis']
4346
self._option.update(xAxis=xaxis, yAxis=yaxis)
4447
self._option.get('legend')[0].get('data').append(name)

pyecharts/charts/boxplot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
# coding=utf-8
32

43
from pyecharts.chart import Chart
@@ -68,11 +67,13 @@ def prepare_data(data):
6867
if m == 0:
6968
_result.append(_d[int(n) - 1])
7069
elif m == 1 / 4:
71-
_result.append(_d[int(n) - 1] * 0.75 + _d[int(n)] * 0.25)
70+
_result.append(
71+
_d[int(n) - 1] * 0.75 + _d[int(n)] * 0.25)
7272
elif m == 1 / 2:
7373
_result.append(_d[int(n) - 1] * 0.5 + _d[int(n)] * 0.5)
7474
elif m == 3 / 4:
75-
_result.append(_d[int(n) - 1] * 0.25 + _d[int(n)] * 0.75)
75+
_result.append(
76+
_d[int(n) - 1] * 0.25 + _d[int(n)] * 0.75)
7677
_result.insert(0, _d[0]) # 最小值
7778
_result.append(_d[-1]) # 最大值
7879
_data.append(_result)

pyecharts/charts/effectscatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __add(self, name, x_axis, y_axis,
4343
self._option.get('series').append({
4444
"type": "effectScatter",
4545
"name": name,
46-
"showEffectOn":"render",
46+
"showEffectOn": "render",
4747
"rippleEffect": chart['effect'],
4848
"symbol": chart['symbol'],
4949
"symbolSize": symbol_size,

pyecharts/charts/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ def __add(self, name, nodes, links, categories=None,
110110
"categories": categories,
111111
"edgeSymbol": graph_edge_symbol,
112112
"edgeSymbolSize": graph_edge_symbolsize,
113-
"links":links,
113+
"links": links,
114114
})
115115
self._config_components(**kwargs)

pyecharts/charts/line.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def __add(self, name, x_axis, y_axis,
5151
chart = get_all_options(**kwargs)
5252

5353
xaxis, yaxis = chart['xy_axis']
54-
is_stack = "stack_" + str(self._option['series_id']) if is_stack else ""
54+
if is_stack:
55+
is_stack = "stack_" + str(self._option['series_id'])
56+
else:
57+
is_stack = ""
5558
_area_style = {"normal": chart['area_style']} if is_fill else {}
5659
self._option.update(xAxis=xaxis, yAxis=yaxis)
5760
self._option.get('legend')[0].get('data').append(name)

pyecharts/charts/polar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __add(self, name, data,
145145
if type not in ("barAngle", "barRadius"):
146146
self._option.update(
147147
angleAxis={
148-
"show":is_angleaxis_show,
148+
"show": is_angleaxis_show,
149149
"type": polar_type,
150150
"data": angle_data,
151151
"clockwise": is_clockwise,

pyecharts/charts/scatter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def draw(self, path, color=None):
8181
for x in range(width):
8282
for y in range(height):
8383
if y < int(height / 2):
84-
imarray[x, y], imarray[x, height-y-1] = imarray[x, height-y-1], imarray[x, y]
84+
(imarray[x, y], imarray[x, height-y-1]) = (
85+
imarray[x, height-y-1], imarray[x, y])
8586
# [:3] 代表着 R, G, B 三原色
8687
result = [(x, y) for x in range(width) for y in range(height)
8788
if imarray[x, y][:3] != color]

pyecharts/charts/wordcloud.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
#!/usr/bin/env python
21
# coding=utf-8
32

43
from pyecharts.chart import Chart
54
from pyecharts.option import gen_color
65

6+
SHAPES = ("cardioid", "diamond", "triangle-forward",
7+
"triangle", "pentagon", "star")
8+
79

810
class WordCloud(Chart):
911
"""
@@ -58,7 +60,7 @@ def __add(self, name, attr, value,
5860

5961
_rmin, _rmax = -90, 90
6062
# 确保设置的形状有效,单词的旋转角度应该设置在 [-90, 90]
61-
if shape in ("cardioid", "diamond", "triangle-forward", "triangle", "pentagon", "star"):
63+
if shape in SHAPES:
6264
_rmin = _rmax = 0
6365
else:
6466
shape = "circle"

0 commit comments

Comments
 (0)