Skip to content

Commit e84574a

Browse files
committed
Remove all type annotations
1 parent 0f283d2 commit e84574a

File tree

4 files changed

+90
-110
lines changed

4 files changed

+90
-110
lines changed

adafruit_ht16k33/bargraph.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
from adafruit_ht16k33.ht16k33 import HT16K33
1414

15-
try:
16-
from typing import Optional
17-
except ImportError:
18-
pass
1915

2016
__version__ = "0.0.0+auto.0"
2117
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HT16K33.git"
@@ -29,14 +25,14 @@ class Bicolor24(HT16K33):
2925
LED_GREEN = 2
3026
LED_YELLOW = 3
3127

32-
def __getitem__(self, key: int) -> Optional[bool]:
28+
def __getitem__(self, key):
3329
# map to HT16K33 row (x) and column (y), see schematic
3430
x = key % 4 + 4 * (key // 12)
3531
y = key // 4 - 3 * (key // 12)
3632
# construct the color value and return it
3733
return self._pixel(x, y) | self._pixel(x + 8, y) << 1
3834

39-
def __setitem__(self, key: int, value: bool) -> None:
35+
def __setitem__(self, key, value):
4036
# map to HT16K33 row (x) and column (y), see schematic
4137
x = key % 4 + 4 * (key // 12)
4238
y = key // 4 - 3 * (key // 12)
@@ -45,7 +41,7 @@ def __setitem__(self, key: int, value: bool) -> None:
4541
# conditionally turn on green LED
4642
self._pixel(x + 8, y, value >> 1)
4743

48-
def fill(self, color: bool) -> None:
44+
def fill(self, color):
4945
"""Fill the whole display with the given color.
5046
5147
:param bool color: Whether to fill the display

adafruit_ht16k33/ht16k33.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
from adafruit_bus_device import i2c_device
1515
from micropython import const
1616

17-
try:
18-
from typing import Union, List, Tuple, Optional
19-
from busio import I2C
20-
except ImportError:
21-
pass
2217

2318
__version__ = "0.0.0+auto.0"
2419
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HT16K33.git"
@@ -42,11 +37,11 @@ class HT16K33:
4237

4338
def __init__(
4439
self,
45-
i2c: I2C,
46-
address: Union[int, Tuple, List] = 0x70,
47-
auto_write: bool = True,
48-
brightness: float = 1.0,
49-
) -> None:
40+
i2c,
41+
address = 0x70,
42+
auto_write = True,
43+
brightness = 1.0,
44+
):
5045
if isinstance(address, (tuple, list)):
5146
self.i2c_device = []
5247
for addr in address:
@@ -65,18 +60,18 @@ def __init__(
6560
self.blink_rate = 0
6661
self.brightness = brightness
6762

68-
def _write_cmd(self, byte: bytearray, i2c_index: int = 0) -> None:
63+
def _write_cmd(self, byte, i2c_index = 0):
6964
self._temp[0] = byte
7065
with self.i2c_device[i2c_index]:
7166
self.i2c_device[i2c_index].write(self._temp)
7267

7368
@property
74-
def blink_rate(self) -> int:
69+
def blink_rate(self):
7570
"""The blink rate. Range 0-3."""
7671
return self._blink_rate
7772

7873
@blink_rate.setter
79-
def blink_rate(self, rate: Optional[int] = None) -> None:
74+
def blink_rate(self, rate = None):
8075
if not 0 <= rate <= 3:
8176
raise ValueError("Blink rate must be an integer in the range: 0-3")
8277
rate = rate & 0x03
@@ -87,12 +82,12 @@ def blink_rate(self, rate: Optional[int] = None) -> None:
8782
)
8883

8984
@property
90-
def brightness(self) -> float:
85+
def brightness(self):
9186
"""The brightness. Range 0.0-1.0"""
9287
return self._brightness
9388

9489
@brightness.setter
95-
def brightness(self, brightness: float) -> None:
90+
def brightness(self, brightness):
9691
if not 0.0 <= brightness <= 1.0:
9792
raise ValueError(
9893
"Brightness must be a decimal number in the range: 0.0-1.0"
@@ -105,18 +100,18 @@ def brightness(self, brightness: float) -> None:
105100
self._write_cmd(_HT16K33_CMD_BRIGHTNESS | xbright, index)
106101

107102
@property
108-
def auto_write(self) -> bool:
103+
def auto_write(self):
109104
"""Auto write updates to the display."""
110105
return self._auto_write
111106

112107
@auto_write.setter
113-
def auto_write(self, auto_write: bool) -> None:
108+
def auto_write(self, auto_write):
114109
if isinstance(auto_write, bool):
115110
self._auto_write = auto_write
116111
else:
117112
raise ValueError("Must set to either True or False.")
118113

119-
def show(self) -> None:
114+
def show(self):
120115
"""Refresh the display and show the changes."""
121116
for index, i2c_dev in enumerate(self.i2c_device):
122117
with i2c_dev:
@@ -126,7 +121,7 @@ def show(self) -> None:
126121
buffer = self._buffer[offset : offset + self._buffer_size]
127122
i2c_dev.write(buffer)
128123

129-
def fill(self, color: bool) -> None:
124+
def fill(self, color):
130125
"""Fill the whole display with the given color.
131126
132127
:param bool color: Whether to fill the display
@@ -139,7 +134,7 @@ def fill(self, color: bool) -> None:
139134
if self._auto_write:
140135
self.show()
141136

142-
def _pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
137+
def _pixel(self, x, y, color = None):
143138
offset = ((x // 16) + (y // 8)) * self._buffer_size
144139
addr = 2 * (y % 8) + ((x % 16) // 8)
145140
addr = (addr % 16) + offset
@@ -156,8 +151,8 @@ def _pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]
156151
self.show()
157152
return None
158153

159-
def _set_buffer(self, i: int, value: bool) -> None:
154+
def _set_buffer(self, i, value):
160155
self._buffer[i + 1] = value # Offset by 1 to move past register address.
161156

162-
def _get_buffer(self, i: int) -> bool:
157+
def _get_buffer(self, i):
163158
return self._buffer[i + 1] # Offset by 1 to move past register address.

adafruit_ht16k33/matrix.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
"""
1111
from adafruit_ht16k33.ht16k33 import HT16K33
1212

13-
try:
14-
from typing import Union, List, Tuple, Optional
15-
from busio import I2C
16-
from PIL import Image
17-
except ImportError:
18-
pass
1913

2014
__version__ = "0.0.0+auto.0"
2115
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HT16K33.git"
@@ -27,7 +21,7 @@ class Matrix8x8(HT16K33):
2721
_columns = 8
2822
_rows = 8
2923

30-
def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
24+
def pixel(self, x, y, color = None):
3125
"""Get or set the color of a given pixel.
3226
3327
:param int x: The x coordinate of the pixel
@@ -43,16 +37,16 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
4337
x = (x - 1) % 8
4438
return super()._pixel(x, y, color)
4539

46-
def __getitem__(self, key: int) -> Optional[bool]:
40+
def __getitem__(self, key):
4741
x, y = key
4842
return self.pixel(x, y)
4943

50-
def __setitem__(self, key: int, value: bool) -> None:
44+
def __setitem__(self, key, value):
5145
x, y = key
5246
self.pixel(x, y, value)
5347

5448
# pylint: disable=too-many-branches
55-
def shift(self, x: int, y: int, rotate: bool = False) -> None:
49+
def shift(self, x, y, rotate = False):
5650
"""
5751
Shift pixels by x and y
5852
@@ -96,39 +90,39 @@ def shift(self, x: int, y: int, rotate: bool = False) -> None:
9690

9791
# pylint: enable=too-many-branches
9892

99-
def shift_right(self, rotate: bool = False) -> None:
93+
def shift_right(self, rotate = False):
10094
"""
10195
Shift all pixels right
10296
10397
:param rotate: (Optional) Rotate the shifted pixels to the left side (default=False)
10498
"""
10599
self.shift(1, 0, rotate)
106100

107-
def shift_left(self, rotate: bool = False) -> None:
101+
def shift_left(self, rotate = False):
108102
"""
109103
Shift all pixels left
110104
111105
:param rotate: (Optional) Rotate the shifted pixels to the right side (default=False)
112106
"""
113107
self.shift(-1, 0, rotate)
114108

115-
def shift_up(self, rotate: bool = False) -> None:
109+
def shift_up(self, rotate = False):
116110
"""
117111
Shift all pixels up
118112
119113
:param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
120114
"""
121115
self.shift(0, 1, rotate)
122116

123-
def shift_down(self, rotate: bool = False) -> None:
117+
def shift_down(self, rotate = False):
124118
"""
125119
Shift all pixels down
126120
127121
:param rotate: (Optional) Rotate the shifted pixels to top (default=False)
128122
"""
129123
self.shift(0, -1, rotate)
130124

131-
def image(self, img: Image) -> None:
125+
def image(self, img):
132126
"""Set buffer to value of Python Imaging Library image. The image should
133127
be in 1 bit mode and a size equal to the display size.
134128
@@ -155,12 +149,12 @@ def image(self, img: Image) -> None:
155149
self.show()
156150

157151
@property
158-
def columns(self) -> int:
152+
def columns(self):
159153
"""Read-only property for number of columns"""
160154
return self._columns
161155

162156
@property
163-
def rows(self) -> int:
157+
def rows(self):
164158
"""Read-only property for number of rows"""
165159
return self._rows
166160

@@ -172,15 +166,15 @@ class Matrix16x8(Matrix8x8):
172166

173167
def __init__(
174168
self,
175-
i2c: I2C,
176-
address: Union[int, Tuple, List] = 0x70,
177-
auto_write: bool = True,
178-
brightness: float = 1.0,
179-
) -> None:
169+
i2c,
170+
address = 0x70,
171+
auto_write = True,
172+
brightness = 1.0,
173+
):
180174
super().__init__(i2c, address, auto_write, brightness)
181175
self._columns *= len(self.i2c_device)
182176

183-
def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
177+
def pixel(self, x, y, color = None):
184178
"""Get or set the color of a given pixel.
185179
186180
:param int x: The x coordinate of the pixel
@@ -204,7 +198,7 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
204198
class MatrixBackpack16x8(Matrix16x8):
205199
"""A double matrix backpack."""
206200

207-
def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
201+
def pixel(self, x, y, color = None):
208202
"""Get or set the color of a given pixel.
209203
210204
:param int x: The x coordinate of the pixel
@@ -229,7 +223,7 @@ class Matrix8x8x2(Matrix8x8):
229223
LED_GREEN = 2
230224
LED_YELLOW = 3
231225

232-
def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
226+
def pixel(self, x, y, color = None):
233227
"""Get or set the color of a given pixel.
234228
235229
:param int x: The x coordinate of the pixel
@@ -249,7 +243,7 @@ def pixel(self, x: int, y: int, color: Optional[bool] = None) -> Optional[bool]:
249243
return super()._pixel(y, x) | super()._pixel(y + 8, x) << 1
250244
return None
251245

252-
def fill(self, color: bool) -> None:
246+
def fill(self, color):
253247
"""Fill the whole display with the given color.
254248
255249
:param bool color: Whether to fill the display
@@ -263,7 +257,7 @@ def fill(self, color: bool) -> None:
263257
if self._auto_write:
264258
self.show()
265259

266-
def image(self, img: Image) -> None:
260+
def image(self, img):
267261
"""Set buffer to value of Python Imaging Library image. The image should
268262
be a size equal to the display size.
269263

0 commit comments

Comments
 (0)