Skip to content

Commit 111487d

Browse files
authored
Merge pull request #23 from tcfranks/main
Add Missing Type Annotations
2 parents d628492 + 485af33 commit 111487d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

adafruit_veml7700.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
from adafruit_register.i2c_bits import RWBits
3838
from adafruit_register.i2c_bit import RWBit, ROBit
3939

40+
try:
41+
import typing # pylint: disable=unused-import
42+
from busio import I2C
43+
except ImportError:
44+
pass
45+
4046
__version__ = "0.0.0+auto.0"
4147
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VEML7700.git"
4248

@@ -185,7 +191,7 @@ class VEML7700:
185191
light_interrupt_low = ROBit(0x06, 15, register_width=2)
186192
"""Ambient light low threshold interrupt flag. Triggered when low threshold exceeded."""
187193

188-
def __init__(self, i2c_bus, address=0x10):
194+
def __init__(self, i2c_bus: I2C, address: int = 0x10) -> None:
189195
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
190196
for _ in range(3):
191197
try:
@@ -196,17 +202,17 @@ def __init__(self, i2c_bus, address=0x10):
196202
else:
197203
raise RuntimeError("Unable to enable VEML7700 device")
198204

199-
def integration_time_value(self):
205+
def integration_time_value(self) -> int:
200206
"""Integration time value in integer form. Used for calculating :meth:`resolution`."""
201207
integration_time = self.light_integration_time
202208
return self.integration_time_values[integration_time]
203209

204-
def gain_value(self):
210+
def gain_value(self) -> float:
205211
"""Gain value in integer form. Used for calculating :meth:`resolution`."""
206212
gain = self.light_gain
207213
return self.gain_values[gain]
208214

209-
def resolution(self):
215+
def resolution(self) -> float:
210216
"""Calculate the :meth:`resolution`` necessary to calculate lux. Based on
211217
integration time and gain settings."""
212218
resolution_at_max = 0.0036
@@ -225,7 +231,7 @@ def resolution(self):
225231
)
226232

227233
@property
228-
def lux(self):
234+
def lux(self) -> float:
229235
"""Light value in lux.
230236
231237
This example prints the light data in lux. Cover the sensor to see the values change.

0 commit comments

Comments
 (0)