Skip to content

Commit c8a663d

Browse files
authored
Merge pull request #12 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 196072d + 737ab7f commit c8a663d

File tree

10 files changed

+194
-124
lines changed

10 files changed

+194
-124
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_display_shapes/circle.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ class Circle(RoundRect):
5656
``None`` for no outline.
5757
5858
"""
59+
5960
def __init__(self, x0, y0, r, *, fill=None, outline=None):
60-
super().__init__(x0-r, y0-r, 2*r+1, 2*r+1, r, fill=fill, outline=outline)
61+
super().__init__(
62+
x0 - r, y0 - r, 2 * r + 1, 2 * r + 1, r, fill=fill, outline=outline
63+
)

adafruit_display_shapes/line.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
__version__ = "0.0.0-auto.0"
4444
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes.git"
4545

46+
4647
class Line(Polygon):
4748
# pylint: disable=too-many-arguments,invalid-name
4849
"""A line.
@@ -53,5 +54,6 @@ class Line(Polygon):
5354
:param y1: The y-position of the second vertex.
5455
:param color: The color of the line.
5556
"""
57+
5658
def __init__(self, x0, y0, x1, y1, color):
5759
super().__init__([(x0, y0), (x1, y1)], outline=color)

adafruit_display_shapes/polygon.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Polygon(displayio.TileGrid):
5454
:param outline: The outline of the polygon. Can be a hex value for a color or
5555
``None`` for no outline.
5656
"""
57+
5758
def __init__(self, points, *, outline=None):
5859
xs = []
5960
ys = []
@@ -82,10 +83,17 @@ def __init__(self, points, *, outline=None):
8283
point_b = points[0]
8384
else:
8485
point_b = points[index + 1]
85-
self._line(point_a[0] - x_offset, point_a[1] - y_offset,
86-
point_b[0] - x_offset, point_b[1] - y_offset, 1)
87-
88-
super().__init__(self._bitmap, pixel_shader=self._palette, x=x_offset, y=y_offset)
86+
self._line(
87+
point_a[0] - x_offset,
88+
point_a[1] - y_offset,
89+
point_b[0] - x_offset,
90+
point_b[1] - y_offset,
91+
1,
92+
)
93+
94+
super().__init__(
95+
self._bitmap, pixel_shader=self._palette, x=x_offset, y=y_offset
96+
)
8997

9098
# pylint: disable=invalid-name, too-many-locals, too-many-branches
9199
def _line(self, x0, y0, x1, y1, color):
@@ -128,6 +136,7 @@ def _line(self, x0, y0, x1, y1, color):
128136
if err < 0:
129137
y0 += ystep
130138
err += dx
139+
131140
# pylint: enable=invalid-name, too-many-locals, too-many-branches
132141

133142
@property

adafruit_display_shapes/rect.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Rect(displayio.TileGrid):
5959
``height``.
6060
6161
"""
62+
6263
def __init__(self, x, y, width, height, *, fill=None, outline=None, stroke=1):
6364
self._bitmap = displayio.Bitmap(width, height, 2)
6465
self._palette = displayio.Palette(2)
@@ -68,11 +69,11 @@ def __init__(self, x, y, width, height, *, fill=None, outline=None, stroke=1):
6869
for w in range(width):
6970
for line in range(stroke):
7071
self._bitmap[w, line] = 1
71-
self._bitmap[w, height-1-line] = 1
72+
self._bitmap[w, height - 1 - line] = 1
7273
for _h in range(height):
7374
for line in range(stroke):
7475
self._bitmap[line, _h] = 1
75-
self._bitmap[width-1-line, _h] = 1
76+
self._bitmap[width - 1 - line, _h] = 1
7677

7778
if fill is not None:
7879
self._palette[0] = fill

adafruit_display_shapes/roundrect.py

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,23 @@ class RoundRect(displayio.TileGrid):
5151
``height``.
5252
5353
"""
54+
5455
def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1):
5556
self._palette = displayio.Palette(3)
5657
self._palette.make_transparent(0)
5758
self._bitmap = displayio.Bitmap(width, height, 3)
58-
for i in range(0, width): # draw the center chunk
59-
for j in range(r, height - r): # draw the center chunk
59+
for i in range(0, width): # draw the center chunk
60+
for j in range(r, height - r): # draw the center chunk
6061
self._bitmap[i, j] = 2
61-
self._helper(r, r, r, color=2, fill=True,
62-
x_offset=width-2*r-1, y_offset=height-2*r-1)
62+
self._helper(
63+
r,
64+
r,
65+
r,
66+
color=2,
67+
fill=True,
68+
x_offset=width - 2 * r - 1,
69+
y_offset=height - 2 * r - 1,
70+
)
6371

6472
if fill is not None:
6573
self._palette[2] = fill
@@ -74,19 +82,37 @@ def __init__(self, x, y, width, height, r, *, fill=None, outline=None, stroke=1)
7482
for w in range(r, width - r):
7583
for line in range(stroke):
7684
self._bitmap[w, line] = 1
77-
self._bitmap[w, height-line-1] = 1
85+
self._bitmap[w, height - line - 1] = 1
7886
for _h in range(r, height - r):
7987
for line in range(stroke):
8088
self._bitmap[line, _h] = 1
81-
self._bitmap[width-line-1, _h] = 1
89+
self._bitmap[width - line - 1, _h] = 1
8290
# draw round corners
83-
self._helper(r, r, r, color=1, stroke=stroke,
84-
x_offset=width-2*r-1, y_offset=height-2*r-1)
91+
self._helper(
92+
r,
93+
r,
94+
r,
95+
color=1,
96+
stroke=stroke,
97+
x_offset=width - 2 * r - 1,
98+
y_offset=height - 2 * r - 1,
99+
)
85100
super().__init__(self._bitmap, pixel_shader=self._palette, x=x, y=y)
86101

87102
# pylint: disable=invalid-name, too-many-locals, too-many-branches
88-
def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
89-
stroke=1, corner_flags=0xF, fill=False):
103+
def _helper(
104+
self,
105+
x0,
106+
y0,
107+
r,
108+
*,
109+
color,
110+
x_offset=0,
111+
y_offset=0,
112+
stroke=1,
113+
corner_flags=0xF,
114+
fill=False
115+
):
90116
f = 1 - r
91117
ddF_x = 1
92118
ddF_y = -2 * r
@@ -103,32 +129,33 @@ def _helper(self, x0, y0, r, *, color, x_offset=0, y_offset=0,
103129
f += ddF_x
104130
if corner_flags & 0x8:
105131
if fill:
106-
for w in range(x0-y, x0+y+x_offset):
107-
self._bitmap[w, y0+x+y_offset] = color
108-
for w in range(x0-x, x0+x+x_offset):
109-
self._bitmap[w, y0+y+y_offset] = color
132+
for w in range(x0 - y, x0 + y + x_offset):
133+
self._bitmap[w, y0 + x + y_offset] = color
134+
for w in range(x0 - x, x0 + x + x_offset):
135+
self._bitmap[w, y0 + y + y_offset] = color
110136
else:
111137
for line in range(stroke):
112-
self._bitmap[x0-y+line, y0+x+y_offset] = color
113-
self._bitmap[x0-x, y0+y+y_offset-line] = color
138+
self._bitmap[x0 - y + line, y0 + x + y_offset] = color
139+
self._bitmap[x0 - x, y0 + y + y_offset - line] = color
114140
if corner_flags & 0x1:
115141
if fill:
116-
for w in range(x0-y, x0+y+x_offset):
117-
self._bitmap[w, y0-x] = color
118-
for w in range(x0-x, x0+x+x_offset):
119-
self._bitmap[w, y0-y] = color
142+
for w in range(x0 - y, x0 + y + x_offset):
143+
self._bitmap[w, y0 - x] = color
144+
for w in range(x0 - x, x0 + x + x_offset):
145+
self._bitmap[w, y0 - y] = color
120146
else:
121147
for line in range(stroke):
122-
self._bitmap[x0-y+line, y0-x] = color
123-
self._bitmap[x0-x, y0-y+line] = color
148+
self._bitmap[x0 - y + line, y0 - x] = color
149+
self._bitmap[x0 - x, y0 - y + line] = color
124150
if corner_flags & 0x4:
125151
for line in range(stroke):
126-
self._bitmap[x0+x+x_offset, y0+y+y_offset-line] = color
127-
self._bitmap[x0+y+x_offset-line, y0+x+y_offset] = color
152+
self._bitmap[x0 + x + x_offset, y0 + y + y_offset - line] = color
153+
self._bitmap[x0 + y + x_offset - line, y0 + x + y_offset] = color
128154
if corner_flags & 0x2:
129155
for line in range(stroke):
130-
self._bitmap[x0+x+x_offset, y0-y+line] = color
131-
self._bitmap[x0+y+x_offset-line, y0-x] = color
156+
self._bitmap[x0 + x + x_offset, y0 - y + line] = color
157+
self._bitmap[x0 + y + x_offset - line, y0 - x] = color
158+
132159
# pylint: enable=invalid-name, too-many-locals, too-many-branches
133160

134161
@property

adafruit_display_shapes/triangle.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def __init__(self, x0, y0, x1, y1, x2, y2, *, fill=None, outline=None):
8282
super().__init__(points)
8383

8484
if fill is not None:
85-
self._draw_filled(x0 - min(xs), 0, x1 - min(xs), y1 - y0, x2 - min(xs), y2 - y0)
85+
self._draw_filled(
86+
x0 - min(xs), 0, x1 - min(xs), y1 - y0, x2 - min(xs), y2 - y0
87+
)
8688
self.fill = fill
8789
else:
8890
self.fill = None
@@ -95,12 +97,17 @@ def __init__(self, x0, y0, x1, y1, x2, y2, *, fill=None, outline=None):
9597
point_b = points[0]
9698
else:
9799
point_b = points[index + 1]
98-
self._line(point_a[0] - min(xs), point_a[1] - y0,
99-
point_b[0] - min(xs), point_b[1] - y0, 1)
100+
self._line(
101+
point_a[0] - min(xs),
102+
point_a[1] - y0,
103+
point_b[0] - min(xs),
104+
point_b[1] - y0,
105+
1,
106+
)
100107

101108
# pylint: disable=invalid-name, too-many-branches
102109
def _draw_filled(self, x0, y0, x1, y1, x2, y2):
103-
if y0 == y2: # Handle awkward all-on-same-line case as its own thing
110+
if y0 == y2: # Handle awkward all-on-same-line case as its own thing
104111
a = x0
105112
b = x0
106113
if x1 < a:
@@ -116,9 +123,9 @@ def _draw_filled(self, x0, y0, x1, y1, x2, y2):
116123
return
117124

118125
if y1 == y2:
119-
last = y1 # Include y1 scanline
126+
last = y1 # Include y1 scanline
120127
else:
121-
last = y1 - 1 # Skip it
128+
last = y1 - 1 # Skip it
122129

123130
# Upper Triangle
124131
for y in range(y0, last + 1):
@@ -135,6 +142,7 @@ def _draw_filled(self, x0, y0, x1, y1, x2, y2):
135142
if a > b:
136143
a, b = b, a
137144
self._line(a, y, b, y, 2)
145+
138146
# pylint: enable=invalid-name, too-many-locals, too-many-branches
139147

140148
@property

0 commit comments

Comments
 (0)