Skip to content

Commit 69f44f9

Browse files
committed
Add missing type annotations
1 parent e5de263 commit 69f44f9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

adafruit_trellism4.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
try:
3434
from typing import List, Optional, Tuple, Union
35+
from typing_extensions import Literal
3536
from microcontroller import Pin
3637
except ImportError:
3738
pass
@@ -43,7 +44,14 @@
4344
class _NeoPixelArray:
4445
"""Creates a NeoPixel array for use in the ``TrellisM4Express`` class."""
4546

46-
def __init__(self, pin: Pin, *, width: int, height: int, rotation: int = 0) -> None:
47+
def __init__(
48+
self,
49+
pin: Pin,
50+
*,
51+
width: int,
52+
height: int,
53+
rotation: Literal[0, 90, 180, 270] = 0,
54+
) -> None:
4755
self._neopixel = neopixel.NeoPixel(pin, width * height, auto_write=True)
4856
if rotation % 90 != 0:
4957
raise ValueError("Only 90 degree rotations supported")
@@ -234,7 +242,7 @@ class TrellisM4Express:
234242
current_press = pressed
235243
"""
236244

237-
def __init__(self, rotation: int = 0) -> None:
245+
def __init__(self, rotation: Literal[0, 90, 180, 270] = 0) -> None:
238246
self._rotation = rotation
239247

240248
# Define NeoPixels

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
Adafruit-Blinka
66
adafruit-circuitpython-matrixkeypad
77
adafruit-circuitpython-neopixel
8+
typing-extensions~=4.0

0 commit comments

Comments
 (0)