Skip to content

type annotation #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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