Skip to content

Commit 34e8662

Browse files
committed
Fix/override pylint remarks
1 parent 064e171 commit 34e8662

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

adafruit_display_shapes/multisparkline.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class MultiSparkline(displayio.TileGrid):
106106
will scroll to the left.
107107
"""
108108

109+
# pylint: disable=too-many-arguments, too-many-instance-attributes
109110
def __init__(
110111
self,
111112
width: int,
@@ -150,6 +151,8 @@ def __init__(
150151

151152
super().__init__(self._bitmap, pixel_shader=self._palette, x=x, y=y)
152153

154+
# pylint: enable=too-many-arguments
155+
153156
def clear_values(self) -> None:
154157
"""Clears _buffer and removes all lines in the group"""
155158
self._bitmap.fill(0)
@@ -208,11 +211,10 @@ def _xintercept(
208211

209212
if slope == 0 and y_1 != horizontal_y: # does not intercept horizontalY
210213
return None
211-
else:
212-
xint = (
213-
horizontal_y - b
214-
) / slope # calculate the x-intercept at position y=horizontalY
215-
return int(xint)
214+
xint = (
215+
horizontal_y - b
216+
) / slope # calculate the x-intercept at position y=horizontalY
217+
return int(xint)
216218

217219
def _add_point(
218220
self,
@@ -234,6 +236,7 @@ def _draw(self) -> None:
234236
for i in range(self._lines):
235237
Polygon.draw(self._bitmap, self._points[i].values(), i + 1, close=False)
236238

239+
# pylint: disable=too-many-locals, too-many-nested-blocks, too-many-branches
237240
def update_line(self, line: int = None) -> None:
238241
"""Update the drawing of the sparkline.
239242
param int|None line: Line to update. Set to None for updating all (default).
@@ -245,9 +248,9 @@ def update_line(self, line: int = None) -> None:
245248
lines = [line]
246249

247250
redraw = False
248-
for l in lines:
251+
for a_line in lines:
249252
# bail out early if we only have a single point
250-
n_points = self._buffers[l].len()
253+
n_points = self._buffers[a_line].len()
251254
if n_points < 2:
252255
continue
253256

@@ -258,21 +261,21 @@ def update_line(self, line: int = None) -> None:
258261
else:
259262
xpitch = self._xpitch
260263

261-
self._points[l].clear() # remove all points
264+
self._points[a_line].clear() # remove all points
262265

263-
for count, value in enumerate(self._buffers[l].values()):
266+
for count, value in enumerate(self._buffers[a_line].values()):
264267
if count == 0:
265-
self._add_point(l, 0, value)
268+
self._add_point(a_line, 0, value)
266269
else:
267270
x = int(xpitch * count)
268271
last_x = int(xpitch * (count - 1))
269-
top = self.y_tops[l]
270-
bottom = self.y_bottoms[l]
272+
top = self.y_tops[a_line]
273+
bottom = self.y_bottoms[a_line]
271274

272275
if (bottom <= last_value <= top) and (
273276
bottom <= value <= top
274277
): # both points are in range, plot the line
275-
self._add_point(l, x, value)
278+
self._add_point(a_line, x, value)
276279

277280
else: # at least one point is out of range, clip one or both ends the line
278281
if ((last_value > top) and (value > top)) or (
@@ -312,7 +315,9 @@ def update_line(self, line: int = None) -> None:
312315
if redraw:
313316
self._draw()
314317

315-
def values(self, line: int) -> List[float]:
318+
# pylint: enable=too-many-locals, too-many-nested-blocks, too-many-branches
319+
320+
def values_of(self, line: int) -> List[float]:
316321
"""Returns the values displayed on the sparkline at given index."""
317322

318323
return self._buffers[line].values()

adafruit_display_shapes/sparkline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Sparkline(MultiSparkline):
6363
will scroll to the left.
6464
"""
6565

66+
# pylint: disable=too-many-arguments
6667
def __init__(
6768
self,
6869
width: int,
@@ -79,6 +80,8 @@ def __init__(
7980
width, height, max_items, [color], dyn_xpitch, [y_min], [y_max], x, y
8081
)
8182

83+
# pylint: enable=too-many-arguments
84+
8285
def add_value(self, value: float, update: bool = True) -> None:
8386
"""Add a value to the sparkline.
8487
@@ -100,4 +103,4 @@ def update(self) -> None:
100103
def values(self) -> List[float]:
101104
"""Returns the values displayed on the sparkline."""
102105

103-
return self._buffers[0].values()
106+
return self.values_of(0)

0 commit comments

Comments
 (0)