Skip to content

Commit 69a8889

Browse files
authored
Merge pull request #57 from tekktrik/doc/add-typing
Add type annotations
2 parents b879a44 + 756048d commit 69a8889

File tree

8 files changed

+167
-112
lines changed

8 files changed

+167
-112
lines changed

adafruit_pybadger/clue.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@
3838

3939
Buttons = namedtuple("Buttons", "a b")
4040

41+
try:
42+
from typing import Type
43+
except ImportError:
44+
pass
45+
4146

4247
class Clue(PyBadgerBase):
4348
"""Class that represents a single CLUE."""
4449

4550
_audio_out = audiopwmio.PWMAudioOut
4651
_neopixel_count = 1
4752

48-
def __init__(self):
53+
def __init__(self) -> None:
4954
super().__init__()
5055

5156
i2c = board.I2C()
@@ -64,7 +69,7 @@ def __init__(self):
6469
self._buttons = KeyStates(self._keys)
6570

6671
@property
67-
def button(self):
72+
def button(self) -> Type[tuple]:
6873
"""The buttons on the board.
6974
7075
Example use:

adafruit_pybadger/cpb_gizmo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
import neopixel
3939
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
4040

41+
try:
42+
from typing import Type
43+
except ImportError:
44+
pass
45+
4146
__version__ = "0.0.0-auto.0"
4247
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
4348

@@ -51,7 +56,7 @@ class CPB_Gizmo(PyBadgerBase):
5156
_audio_out = audiopwmio.PWMAudioOut
5257
_neopixel_count = 10
5358

54-
def __init__(self):
59+
def __init__(self) -> None:
5560
super().__init__()
5661

5762
_i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
@@ -74,7 +79,7 @@ def __init__(self):
7479
self._light_sensor = analogio.AnalogIn(board.LIGHT)
7580

7681
@property
77-
def button(self):
82+
def button(self) -> Type[tuple]:
7883
"""The buttons on the board.
7984
8085
Example use:

adafruit_pybadger/magtag.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
import neopixel
3131
from adafruit_pybadger.pybadger_base import PyBadgerBase
3232

33+
try:
34+
from typing import Type
35+
except ImportError:
36+
pass
37+
3338
__version__ = "0.0.0-auto.0"
3439
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
3540

@@ -41,7 +46,7 @@ class MagTag(PyBadgerBase):
4146

4247
_neopixel_count = 4
4348

44-
def __init__(self):
49+
def __init__(self) -> None:
4550
super().__init__()
4651

4752
# NeoPixels
@@ -50,7 +55,7 @@ def __init__(self):
5055
)
5156

5257
@property
53-
def button(self):
58+
def button(self) -> Type[tuple]:
5459
"""The buttons on the board.
5560
5661
Example use:

adafruit_pybadger/pewpewm4.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
import keypad
3232
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
3333

34+
try:
35+
from typing import Type
36+
except ImportError:
37+
pass
38+
3439
__version__ = "0.0.0-auto.0"
3540
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
3641

@@ -43,7 +48,7 @@ class PewPewM4(PyBadgerBase):
4348
_audio_out = audioio.AudioOut
4449
_neopixel_count = 0
4550

46-
def __init__(self):
51+
def __init__(self) -> None:
4752
super().__init__()
4853

4954
self._keys = keypad.Keys(
@@ -63,7 +68,7 @@ def __init__(self):
6368
self._buttons = KeyStates(self._keys)
6469

6570
@property
66-
def button(self):
71+
def button(self) -> Type[tuple]:
6772
"""The buttons on the board.
6873
6974
Example use:

adafruit_pybadger/pybadge.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
import neopixel
4141
from adafruit_pybadger.pybadger_base import PyBadgerBase, KeyStates
4242

43+
try:
44+
from typing import Type
45+
except ImportError:
46+
pass
47+
4348
__version__ = "0.0.0-auto.0"
4449
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PyBadger.git"
4550

@@ -52,7 +57,7 @@ class PyBadge(PyBadgerBase):
5257
_audio_out = audioio.AudioOut
5358
_neopixel_count = 5
5459

55-
def __init__(self):
60+
def __init__(self) -> None:
5661
super().__init__()
5762

5863
i2c = None
@@ -100,7 +105,7 @@ def __init__(self):
100105
self._light_sensor = analogio.AnalogIn(board.A7)
101106

102107
@property
103-
def button(self):
108+
def button(self) -> Type[tuple]:
104109
"""The buttons on the board.
105110
106111
Example use:

0 commit comments

Comments
 (0)