Skip to content

Add Missing Type Annotations #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions adafruit_veml7700.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
from adafruit_register.i2c_bits import RWBits
from adafruit_register.i2c_bit import RWBit, ROBit

try:
import typing # pylint: disable=unused-import
from busio import I2C
except ImportError:
pass

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VEML7700.git"

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

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

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

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

def resolution(self):
def resolution(self) -> float:
"""Calculate the :meth:`resolution`` necessary to calculate lux. Based on
integration time and gain settings."""
resolution_at_max = 0.0036
Expand All @@ -225,7 +231,7 @@ def resolution(self):
)

@property
def lux(self):
def lux(self) -> float:
"""Light value in lux.

This example prints the light data in lux. Cover the sensor to see the values change.
Expand Down