Skip to content

Commit

Permalink
Merge pull request #16 from gtbcoding/isssue/13-type-annotation
Browse files Browse the repository at this point in the history
type annotation
  • Loading branch information
FoamyGuy committed Jun 5, 2023
2 parents 36141a6 + 90f5d75 commit 7b5a196
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions adafruit_matrixkeypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,29 @@
# 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"


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
Expand All @@ -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 = []

Expand Down

0 comments on commit 7b5a196

Please sign in to comment.