Skip to content

Commit 8fda975

Browse files
authored
Pylint fixes
Fix some of the old warnings, reenable some of overrides
1 parent 2e28750 commit 8fda975

File tree

1 file changed

+46
-40
lines changed

1 file changed

+46
-40
lines changed

adafruit_display_shapes/polygon.py

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def __init__(
5555
close: Optional[bool] = True,
5656
colors: Optional[int] = 2,
5757
) -> None:
58-
(xs, ys) = zip(*points)
58+
(x_s, y_s) = zip(*points)
5959

60-
x_offset = min(xs)
61-
y_offset = min(ys)
60+
x_offset = min(x_s)
61+
y_offset = min(y_s)
6262

6363
# Find the largest and smallest X values to figure out width for bitmap
64-
width = max(xs) - min(xs) + 1
65-
height = max(ys) - min(ys) + 1
64+
width = max(x_s) - min(x_s) + 1
65+
height = max(y_s) - min(y_s) + 1
6666

6767
self._palette = displayio.Palette(colors + 1)
6868
self._palette.make_transparent(0)
@@ -99,64 +99,70 @@ def draw(
9999
for index in range(len(points) - 1):
100100
Polygon._line_on(bitmap, points[index], points[index + 1], color_id)
101101

102+
# pylint: disable=too-many-arguments
102103
def _line(
103104
self,
104-
x0: int,
105-
y0: int,
106-
x1: int,
107-
y1: int,
105+
x_0: int,
106+
y_0: int,
107+
x_1: int,
108+
y_1: int,
108109
color: int,
109110
) -> None:
110-
self._line_on(self._bitmap, (x0, y0), (x1, y1), color)
111+
self._line_on(self._bitmap, (x_0, y_0), (x_1, y_1), color)
111112

113+
# pylint: enable=too-many-arguments
114+
115+
# pylint: disable=too-many-branches, too-many-locals
112116
@staticmethod
113117
def _line_on(
114118
bitmap: displayio.Bitmap,
115-
p0: Tuple[int, int],
116-
p1: Tuple[int, int],
119+
p_0: Tuple[int, int],
120+
p_1: Tuple[int, int],
117121
color: int,
118122
) -> None:
119-
(x0, y0) = p0
120-
(x1, y1) = p1
121-
if x0 == x1:
122-
if y0 > y1:
123-
y0, y1 = y1, y0
124-
for _h in range(y0, y1 + 1):
125-
bitmap[x0, _h] = color
126-
elif y0 == y1:
127-
if x0 > x1:
128-
x0, x1 = x1, x0
129-
for _w in range(x0, x1 + 1):
130-
bitmap[_w, y0] = color
123+
(x_0, y_0) = p_0
124+
(x_1, y_1) = p_1
125+
if x_0 == x_1:
126+
if y_0 > y_1:
127+
y_0, y_1 = y_1, y_0
128+
for _h in range(y_0, y_1 + 1):
129+
bitmap[x_0, _h] = color
130+
elif y_0 == y_1:
131+
if x_0 > x_1:
132+
x_0, x_1 = x_1, x_0
133+
for _w in range(x_0, x_1 + 1):
134+
bitmap[_w, y_0] = color
131135
else:
132-
steep = abs(y1 - y0) > abs(x1 - x0)
136+
steep = abs(y_1 - y_0) > abs(x_1 - x_0)
133137
if steep:
134-
x0, y0 = y0, x0
135-
x1, y1 = y1, x1
138+
x_0, y_0 = y_0, x_0
139+
x_1, y_1 = y_1, x_1
136140

137-
if x0 > x1:
138-
x0, x1 = x1, x0
139-
y0, y1 = y1, y0
141+
if x_0 > x_1:
142+
x_0, x_1 = x_1, x_0
143+
y_0, y_1 = y_1, y_0
140144

141-
dx = x1 - x0
142-
dy = abs(y1 - y0)
145+
d_x = x_1 - x_0
146+
d_y = abs(y_1 - y_0)
143147

144-
err = dx / 2
148+
err = d_x / 2
145149

146-
if y0 < y1:
150+
if y_0 < y_1:
147151
ystep = 1
148152
else:
149153
ystep = -1
150154

151-
for x in range(x0, x1 + 1):
155+
for x in range(x_0, x_1 + 1):
152156
if steep:
153-
bitmap[y0, x] = color
157+
bitmap[y_0, x] = color
154158
else:
155-
bitmap[x, y0] = color
156-
err -= dy
159+
bitmap[x, y_0] = color
160+
err -= d_y
157161
if err < 0:
158-
y0 += ystep
159-
err += dx
162+
y_0 += ystep
163+
err += d_x
164+
165+
# pylint: enable=too-many-branches, too-many-locals
160166

161167
@property
162168
def outline(self) -> Optional[int]:

0 commit comments

Comments
 (0)