Skip to content

Commit a39d006

Browse files
committed
Add typing
1 parent 832ccf7 commit a39d006

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

adafruit_74hc595.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import digitalio
2929
import adafruit_bus_device.spi_device as spi_device
3030

31+
32+
3133
__version__ = "0.0.0-auto.0"
3234
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_74HC595.git"
3335

@@ -39,7 +41,7 @@ class DigitalInOut:
3941
direction as input will raise an exception.
4042
"""
4143

42-
def __init__(self, pin_number, shift_register_74hc595):
44+
def __init__(self, pin_number: 'microcontroller.Pin', shift_register_74hc595: 'ShiftRegister74HC595'):
4345
"""Specify the pin number of the shift register (0...7) and
4446
ShiftRegister74HC595 instance.
4547
"""
@@ -53,7 +55,7 @@ def __init__(self, pin_number, shift_register_74hc595):
5355
# is unused by this class). Do not remove them, instead turn off pylint
5456
# in this case.
5557
# pylint: disable=unused-argument
56-
def switch_to_output(self, value=False, **kwargs):
58+
def switch_to_output(self, value: bool = False, **kwargs):
5759
"""``DigitalInOut switch_to_output``"""
5860
self.direction = digitalio.Direction.OUTPUT
5961
self.value = value
@@ -72,7 +74,7 @@ def value(self):
7274
)
7375

7476
@value.setter
75-
def value(self, val):
77+
def value(self, val: bool):
7678

7779
if (
7880
self._pin >= 0
@@ -91,7 +93,7 @@ def direction(self):
9193
return digitalio.Direction.OUTPUT
9294

9395
@direction.setter
94-
def direction(self, val): # pylint: disable=no-self-use
96+
def direction(self, val: digitalio.Direction): # pylint: disable=no-self-use
9597
"""``Direction`` can only be set to ``OUTPUT``."""
9698
if val != digitalio.Direction.OUTPUT:
9799
raise RuntimeError("Digital input not supported.")
@@ -102,7 +104,7 @@ def pull(self):
102104
return None
103105

104106
@pull.setter
105-
def pull(self, val): # pylint: disable=no-self-use
107+
def pull(self, val: digitalio.Pull): # pylint: disable=no-self-use
106108
"""Only supports null/no pull state."""
107109
if val is not None:
108110
raise RuntimeError("Pull-up and pull-down not supported.")
@@ -113,7 +115,7 @@ class ShiftRegister74HC595:
113115
and indicate the number of shift registers being used
114116
"""
115117

116-
def __init__(self, spi, latch, number_of_shift_registers=1):
118+
def __init__(self, spi: 'busio.I2C', latch: digitalio.DigitalInOut, number_of_shift_registers: int = 1):
117119
self._device = spi_device.SPIDevice(spi, latch, baudrate=1000000)
118120
self._number_of_shift_registers = number_of_shift_registers
119121
self._gpio = bytearray(self._number_of_shift_registers)
@@ -131,14 +133,14 @@ def gpio(self):
131133
return self._gpio
132134

133135
@gpio.setter
134-
def gpio(self, val):
136+
def gpio(self, val: '_typing.ReadableBuffer'):
135137
self._gpio = val
136138

137139
with self._device as spi:
138140
# pylint: disable=no-member
139141
spi.write(self._gpio)
140142

141-
def get_pin(self, pin):
143+
def get_pin(self, pin: int) -> 'microcontroller.Pin':
142144
"""Convenience function to create an instance of the DigitalInOut class
143145
pointing at the specified pin of this 74HC595 device .
144146
"""

0 commit comments

Comments
 (0)