diff --git a/adafruit_pcf8591/analog_in.py b/adafruit_pcf8591/analog_in.py index e9023c8..8a9725f 100644 --- a/adafruit_pcf8591/analog_in.py +++ b/adafruit_pcf8591/analog_in.py @@ -29,7 +29,8 @@ try: import typing # pylint: disable=unused-import - from adafruit_pcf8591.pcf8591.PCF8591 import PCF8591 + from typing_extensions import Literal + from adafruit_pcf8591.pcf8591 import PCF8591 except ImportError: pass @@ -37,11 +38,11 @@ class AnalogIn: """AnalogIn Mock Implementation for ADC Reads.""" - def __init__(self, pcf: PCF8591, pin: int) -> None: + def __init__(self, pcf: PCF8591, pin: Literal[0, 1, 2, 3]) -> None: """AnalogIn :param pcf: The PCF8591 object. - :param int pin: Required ADC channel pin. + :param int pin: Required ADC channel pin; must be 0-3 inclusive """ self._pcf = pcf diff --git a/adafruit_pcf8591/analog_out.py b/adafruit_pcf8591/analog_out.py index 348f0a2..428627b 100644 --- a/adafruit_pcf8591/analog_out.py +++ b/adafruit_pcf8591/analog_out.py @@ -28,7 +28,8 @@ """ try: import typing # pylint: disable=unused-import - from adafruit_pcf8591.pcf8591.PCF8591 import PCF8591 + from typing_extensions import Literal + from adafruit_pcf8591.pcf8591 import PCF8591 except ImportError: pass @@ -36,11 +37,11 @@ class AnalogOut: """AnalogIn Mock Implementation for ADC Reads.""" - def __init__(self, pcf: PCF8591, dac_pin: int = 0) -> None: + def __init__(self, pcf: PCF8591, dac_pin: Literal[0] = 0) -> None: """AnalogIn :param pcf: The pcf object. - :param int pin: Required pin must be adafruit_pcf8591.pcf8591.A0 + :param int dac_pin: Required pin must be adafruit_pcf8591.pcf8591.A0 """ self._pcf = pcf diff --git a/adafruit_pcf8591/pcf8591.py b/adafruit_pcf8591/pcf8591.py index a2c798d..96aef52 100644 --- a/adafruit_pcf8591/pcf8591.py +++ b/adafruit_pcf8591/pcf8591.py @@ -97,7 +97,7 @@ def _half_read(self, channel: Literal[0, 1, 2, 3]) -> None: with self.i2c_device as i2c: i2c.write_then_readinto(self._buffer, self._buffer) - def read(self, channel: Literal[0, 1, 2, 3]) -> None: + def read(self, channel: Literal[0, 1, 2, 3]) -> int: """Read an analog value from one of the four ADC inputs :param int channel: The single-ended ADC channel to read from, 0 thru 3