Skip to content

Commit e8eca21

Browse files
committed
mypy fixes
1 parent c37f0c2 commit e8eca21

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

adafruit_neotrellis/multitrellis.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
from typing import List, Sequence
3333

34-
from adafruit_neotrellis.neotrellis import NeoTrellis
34+
from adafruit_neotrellis.neotrellis import CallbackType, NeoTrellis
35+
from adafruit_seesaw.neopixel import PixelType
3536

3637

3738
class MultiTrellis:
@@ -42,7 +43,7 @@ class MultiTrellis:
4243
_cols: int
4344
_key_pads: List[List[NeoTrellis]]
4445

45-
def __init__(self, neotrellis_array):
46+
def __init__(self, neotrellis_array: List[List[NeoTrellis]]):
4647
self._trelli = neotrellis_array
4748
self._rows = len(neotrellis_array)
4849
self._cols = len(neotrellis_array[0])
@@ -107,7 +108,7 @@ def __getitem__(self, subscript: int) -> Sequence[NeoTrellis]:
107108
def get_keypad(self, x: int, y: int) -> NeoTrellis:
108109
return self._key_pads[y][x]
109110

110-
def activate_key(self, x, y, edge, enable=True):
111+
def activate_key(self, x: int, y: int, edge: int, enable: bool = True):
111112
"""Activate or deactivate a key on the trellis. x and y are the index
112113
of the key measured from the top lefthand corner. Edge specifies what
113114
edge to register an event on and can be NeoTrellis.EDGE_FALLING or
@@ -116,13 +117,13 @@ def activate_key(self, x, y, edge, enable=True):
116117
pad = self._key_pads[y][x]
117118
pad.activate_key(pad.key_index(x, y), enable)
118119

119-
def set_callback(self, x, y, function):
120+
def set_callback(self, x: int, y: int, function: CallbackType):
120121
"""Set a callback function for when an event for the key at index x, y
121122
(measured from the top lefthand corner) is detected."""
122123
pad = self._key_pads[y][x]
123124
pad.callbacks[pad.key_index(x, y)] = function
124125

125-
def color(self, x, y, color):
126+
def color(self, x: int, y: int, color: PixelType):
126127
"""Set the color of the pixel at index x, y measured from the top
127128
lefthand corner of the matrix"""
128129
pad = self._key_pads[y][x]
@@ -137,7 +138,7 @@ def data_pending(self) -> bool:
137138
return True
138139
return False
139140

140-
def sync(self):
141+
def sync(self) -> None:
141142
"""Read all trellis boards in the matrix and call any callbacks"""
142143
for py in range(self._rows):
143144
for px in range(self._cols):

adafruit_neotrellis/neotrellis.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
_NEO_TRELLIS_NUM_KEYS = const(64)
6464

6565

66+
CallbackType = Callable[[KeyEvent], None]
67+
68+
6669
class NeoTrellis(Keypad):
6770
"""Driver for the Adafruit NeoTrellis."""
6871

@@ -71,7 +74,7 @@ class NeoTrellis(Keypad):
7174
x_base: int
7275
y_base: int
7376
interrupt_enabled: bool
74-
callbacks: List[Optional[Callable[[KeyEvent], None]]]
77+
callbacks: List[Optional[CallbackType]]
7578
pixels: NeoPixel
7679

7780
def __init__(self, i2c_bus, interrupt=False,

0 commit comments

Comments
 (0)