Skip to content

Commit e0a85be

Browse files
committed
Corrected Type Annotations
1 parent 3d64ac0 commit e0a85be

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

adafruit_display_shapes/line.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
2222
"""
2323

24+
try:
25+
from typing import Optional
26+
except ImportError:
27+
pass
28+
2429
from adafruit_display_shapes.polygon import Polygon
2530

2631
__version__ = "0.0.0-auto.0"
@@ -49,11 +54,11 @@ def __init__(
4954
super().__init__([(x0, y0), (x1, y1)], outline=color)
5055

5156
@property
52-
def color(self) -> int:
57+
def color(self) -> Optional[int]:
5358
"""The line color value. Can be a hex value for a color or
5459
``None`` for no line color."""
5560
return self.outline
5661

5762
@color.setter
58-
def color(self, color: int) -> None:
63+
def color(self, color: Optional[int]) -> None:
5964
self.outline = color

adafruit_display_shapes/polygon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ def _line(
138138
# pylint: enable=invalid-name, too-many-locals, too-many-branches
139139

140140
@property
141-
def outline(self) -> int:
141+
def outline(self) -> Optional[int]:
142142
"""The outline of the polygon. Can be a hex value for a color or
143143
``None`` for no outline."""
144144
return self._palette[1]
145145

146146
@outline.setter
147-
def outline(self, color: int) -> None:
147+
def outline(self, color: Optional[int]) -> None:
148148
if color is None:
149149
self._palette[1] = 0
150150
self._palette.make_transparent(1)

adafruit_display_shapes/rect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ def __init__(
8282
super().__init__(self._bitmap, pixel_shader=self._palette, x=x, y=y)
8383

8484
@property
85-
def fill(self) -> int:
85+
def fill(self) -> Optional[int]:
8686
"""The fill of the rectangle. Can be a hex value for a color or ``None`` for
8787
transparent."""
8888
return self._palette[0]
8989

9090
@fill.setter
91-
def fill(self, color: int) -> None:
91+
def fill(self, color: Optional[int]) -> None:
9292
if color is None:
9393
self._palette[0] = 0
9494
self._palette.make_transparent(0)
@@ -97,13 +97,13 @@ def fill(self, color: int) -> None:
9797
self._palette.make_opaque(0)
9898

9999
@property
100-
def outline(self) -> int:
100+
def outline(self) -> Optional[int]:
101101
"""The outline of the rectangle. Can be a hex value for a color or ``None``
102102
for no outline."""
103103
return self._palette[1]
104104

105105
@outline.setter
106-
def outline(self, color: int) -> None:
106+
def outline(self, color: Optional[int]) -> None:
107107
if color is None:
108108
self._palette[1] = 0
109109
self._palette.make_transparent(1)

adafruit_display_shapes/roundrect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ def _helper(
158158
# pylint: enable=invalid-name, too-many-locals, too-many-branches
159159

160160
@property
161-
def fill(self) -> int:
161+
def fill(self) -> Optional[int]:
162162
"""The fill of the rounded-corner rectangle. Can be a hex value for a color or ``None`` for
163163
transparent."""
164164
return self._palette[2]
165165

166166
@fill.setter
167-
def fill(self, color: int) -> None:
167+
def fill(self, color: Optional[int]) -> None:
168168
if color is None:
169169
self._palette[2] = 0
170170
self._palette.make_transparent(2)
@@ -173,13 +173,13 @@ def fill(self, color: int) -> None:
173173
self._palette.make_opaque(2)
174174

175175
@property
176-
def outline(self) -> int:
176+
def outline(self) -> Optional[int]:
177177
"""The outline of the rounded-corner rectangle. Can be a hex value for a color or ``None``
178178
for no outline."""
179179
return self._palette[1]
180180

181181
@outline.setter
182-
def outline(self, color: int) -> None:
182+
def outline(self, color: Optional[int]) -> None:
183183
if color is None:
184184
self._palette[1] = 0
185185
self._palette.make_transparent(1)

adafruit_display_shapes/sparkline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def add_value(self, value: float) -> None:
115115
# pylint: disable=no-else-return
116116
@staticmethod
117117
def _xintercept(
118-
x_1: int,
118+
x_1: float,
119119
y_1: float,
120-
x_2: int,
120+
x_2: float,
121121
y_2: float,
122-
horizontal_y: int,
122+
horizontal_y: float,
123123
) -> Optional[
124124
int
125125
]: # finds intercept of the line and a horizontal line at horizontalY

adafruit_display_shapes/triangle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ def _draw_filled(
153153
# pylint: enable=invalid-name, too-many-locals, too-many-branches
154154

155155
@property
156-
def fill(self) -> int:
156+
def fill(self) -> Optional[int]:
157157
"""The fill of the triangle. Can be a hex value for a color or
158158
``None`` for transparent."""
159159
return self._palette[2]
160160

161161
@fill.setter
162-
def fill(self, color: int) -> None:
162+
def fill(self, color: Optional[int]) -> None:
163163
if color is None:
164164
self._palette[2] = 0
165165
self._palette.make_transparent(2)

0 commit comments

Comments
 (0)