Skip to content

Commit

Permalink
mypy error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeharker committed Oct 25, 2024
1 parent f44be3b commit 523e785
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions adafruit_neotrellis/neotrellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_neotrellis.git"

from time import sleep
from typing import List, Callable
from micropython import const
from adafruit_seesaw.keypad import Keypad, KeyEvent, SeesawKeyResponse, ResponseType
from typing import Callable, List, Optional

from adafruit_seesaw.keypad import KeyEvent, Keypad, ResponseType
from adafruit_seesaw.neopixel import NeoPixel
from micropython import const


_NEO_TRELLIS_ADDR = const(0x2E)

Expand All @@ -68,8 +70,8 @@ class NeoTrellis(Keypad):
x_base: int
y_base: int
interrupt_enabled: bool
callbacks: List[Callable[[KeyEvent], None]]
pixels: List[NeoPixel]
callbacks: List[Optional[Callable[[KeyEvent], None]]]
pixels: NeoPixel

def __init__(self, i2c_bus, interrupt=False,
addr=_NEO_TRELLIS_ADDR, drdy=None,
Expand Down Expand Up @@ -107,11 +109,12 @@ def sync(self):
if r.response_type == ResponseType.TYPE_KEY:
(e, n) = r.data_edge_num()
evt = KeyEvent(n, e)
callback = self.callbacks[evt.number]
if (
evt.number < _NEO_TRELLIS_NUM_KEYS
and self.callbacks[evt.number] is not None
callback is not None
and evt.number < _NEO_TRELLIS_NUM_KEYS
):
self.callbacks[evt.number](evt)
callback(evt)

def local_key_index(self, x, y):
return int(y * self.width + x)
Expand Down

0 comments on commit 523e785

Please sign in to comment.