Skip to content

Commit 2d4dcec

Browse files
authored
Merge pull request #12 from tcfranks/main
Add Missing Type Annotations
2 parents 1e6383b + 6b004d0 commit 2d4dcec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

adafruit_ds3502.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
from adafruit_register.i2c_bit import RWBit
4242
import adafruit_bus_device.i2c_device as i2cdevice
4343

44+
try:
45+
import typing # pylint: disable=unused-import
46+
from busio import I2C
47+
except ImportError:
48+
pass
49+
4450
_REG_WIPER = const(0x00) # Wiper value register (R/W)
4551
_REG_CONTROL = const(0x02) # Configuration Register (R/W)
4652

@@ -52,7 +58,7 @@ class DS3502:
5258
:param address: The I2C device address for the sensor. Default is ``0x40``.
5359
"""
5460

55-
def __init__(self, i2c_bus, address=0x28):
61+
def __init__(self, i2c_bus: I2C, address: int = 0x28) -> None:
5662
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
5763

5864
# set to mode 1 on init to not write to the IVR every time you set
@@ -62,20 +68,20 @@ def __init__(self, i2c_bus, address=0x28):
6268
_write_only_to_wiper = RWBit(_REG_CONTROL, 7)
6369

6470
@property
65-
def wiper(self):
71+
def wiper(self) -> int:
6672
"""The value of the potentionmeter's wiper.
6773
6874
:param wiper_value: The value from 0-127 to set the wiper to.
6975
"""
7076
return self._wiper
7177

7278
@wiper.setter
73-
def wiper(self, value):
79+
def wiper(self, value: int) -> None:
7480
if value < 0 or value > 127:
7581
raise ValueError("wiper must be from 0-127")
7682
self._wiper = value
7783

78-
def set_default(self, default):
84+
def set_default(self, default: int) -> None:
7985
"""Sets the wiper's default value and current value to the given value
8086
8187
:param new_default: The value from 0-127 to set as the wiper's default.

0 commit comments

Comments
 (0)