diff --git a/adafruit_matrixkeypad.py b/adafruit_matrixkeypad.py index e951b4e..5f0857b 100644 --- a/adafruit_matrixkeypad.py +++ b/adafruit_matrixkeypad.py @@ -27,6 +27,14 @@ # imports from digitalio import Direction, Pull +# Since the board may or may not have access to the typing library we need +# to have this in a try/except to enable type +try: + from typing import List + from digitalio import DigitalInOut +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MatrixKeypad.git" @@ -34,8 +42,14 @@ class Matrix_Keypad: """Driver for passive matrix keypads - any size""" - def __init__(self, row_pins, col_pins, keys): - """Initialise the driver with the correct size and key list. + def __init__( + self, + row_pins: List[DigitalInOut], + col_pins: List[DigitalInOut], + keys: List[List], + ) -> None: + """ + Initialise the driver with the correct size and key list. :param list row_pins: a list of DigitalInOut objects corresponding to the rows :param list col_pins: a list of DigitalInOut objects corresponding to the colums @@ -51,9 +65,13 @@ def __init__(self, row_pins, col_pins, keys): self.keys = keys @property - def pressed_keys(self): - """An array containing all detected keys that are pressed from the initalized - list-of-lists passed in during creation""" + def pressed_keys(self) -> List: + """ + An array containing all detected keys that are pressed from the initalized + list-of-lists passed in during creation + + :return: a list of keys that are pressed + """ # make a list of all the keys that are detected pressed = []