Skip to content

Commit 47ddfe1

Browse files
authored
Merge pull request #10 from tekktrik/dev/fix-typing
Fix type annotations
2 parents 7a217f6 + 1552eab commit 47ddfe1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

adafruit_pcf8591/analog_in.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,20 @@
2929

3030
try:
3131
import typing # pylint: disable=unused-import
32-
from adafruit_pcf8591.pcf8591.PCF8591 import PCF8591
32+
from typing_extensions import Literal
33+
from adafruit_pcf8591.pcf8591 import PCF8591
3334
except ImportError:
3435
pass
3536

3637

3738
class AnalogIn:
3839
"""AnalogIn Mock Implementation for ADC Reads."""
3940

40-
def __init__(self, pcf: PCF8591, pin: int) -> None:
41+
def __init__(self, pcf: PCF8591, pin: Literal[0, 1, 2, 3]) -> None:
4142
"""AnalogIn
4243
4344
:param pcf: The PCF8591 object.
44-
:param int pin: Required ADC channel pin.
45+
:param int pin: Required ADC channel pin; must be 0-3 inclusive
4546
4647
"""
4748
self._pcf = pcf

adafruit_pcf8591/analog_out.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@
2828
"""
2929
try:
3030
import typing # pylint: disable=unused-import
31-
from adafruit_pcf8591.pcf8591.PCF8591 import PCF8591
31+
from typing_extensions import Literal
32+
from adafruit_pcf8591.pcf8591 import PCF8591
3233
except ImportError:
3334
pass
3435

3536

3637
class AnalogOut:
3738
"""AnalogIn Mock Implementation for ADC Reads."""
3839

39-
def __init__(self, pcf: PCF8591, dac_pin: int = 0) -> None:
40+
def __init__(self, pcf: PCF8591, dac_pin: Literal[0] = 0) -> None:
4041
"""AnalogIn
4142
4243
:param pcf: The pcf object.
43-
:param int pin: Required pin must be adafruit_pcf8591.pcf8591.A0
44+
:param int dac_pin: Required pin must be adafruit_pcf8591.pcf8591.A0
4445
4546
"""
4647
self._pcf = pcf

adafruit_pcf8591/pcf8591.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _half_read(self, channel: Literal[0, 1, 2, 3]) -> None:
9797
with self.i2c_device as i2c:
9898
i2c.write_then_readinto(self._buffer, self._buffer)
9999

100-
def read(self, channel: Literal[0, 1, 2, 3]) -> None:
100+
def read(self, channel: Literal[0, 1, 2, 3]) -> int:
101101
"""Read an analog value from one of the four ADC inputs
102102
103103
:param int channel: The single-ended ADC channel to read from, 0 thru 3

0 commit comments

Comments
 (0)