Skip to content

Commit 161994d

Browse files
committed
add corrections per suggestions - did away with Literal, so removed typing-extensions from requirements.txt
1 parent d13a609 commit 161994d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

adafruit_ltr390.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
from adafruit_register.i2c_bit import RWBit, ROBit
3838

3939
try:
40-
from typing import Optional, Tuple, Type, Union
41-
from typing_extensions import Literal
40+
from typing import Optional, Tuple, Type
4241
from busio import I2C
4342
except ImportError:
4443
pass
@@ -74,8 +73,8 @@ def __init__(self, register_address, struct_format, bitwidth, length):
7473

7574
def __get__(
7675
self,
77-
obj: Optional["UnalignedStruct"],
78-
objtype: Optional[Type["UnalignedStruct"]] = None,
76+
obj: Optional["LTR390"],
77+
objtype: Optional[Type["LTR390"]] = None,
7978
) -> int:
8079
# read bytes into buffer at correct alignment
8180
raw_value = unpack_from(self.format, self.buffer, offset=1)[0]
@@ -92,7 +91,7 @@ def __get__(
9291
raw_value = unpack_from(self.format, self.buffer, offset=1)[0]
9392
return raw_value >> 8
9493

95-
def __set__(self, obj: Optional["UnalignedStruct"], value: int) -> None:
94+
def __set__(self, obj: Optional["LTR390"], value: int) -> None:
9695
pack_into(self.format, self.buffer, 1, value)
9796
with obj.i2c_device as i2c:
9897
i2c.write(self.buffer)
@@ -104,7 +103,7 @@ class CV:
104103
@classmethod
105104
def add_values(
106105
cls,
107-
value_tuples: Tuple[str, int, str, Union[int, None], int, Union[float, None]],
106+
value_tuples: Tuple[str, int, str, Optional[float], int, Optional[float]],
108107
) -> None:
109108
"""Add CV values to the class"""
110109
cls.string = {}
@@ -330,11 +329,11 @@ def _reset(self) -> None:
330329
i2c.write(bytes((_THRESH_LOW, 0x00, 0x00, 0x00)))
331330

332331
@property
333-
def _mode(self) -> Literal[0, 1]:
332+
def _mode(self) -> bool:
334333
return self._mode_bit
335334

336335
@_mode.setter
337-
def _mode(self, value: Literal[0, 1]) -> None:
336+
def _mode(self, value: bool) -> None:
338337
if not value in [ALS, UV]:
339338
raise AttributeError("Mode must be ALS or UV")
340339
if self._mode_cache != value:
@@ -381,9 +380,7 @@ def resolution(self, value: int):
381380
raise AttributeError("resolution must be a Resolution")
382381
self._resolution_bits = value
383382

384-
def enable_alerts(
385-
self, enable: bool, source: Literal[0, 1], persistance: int
386-
) -> None:
383+
def enable_alerts(self, enable: bool, source: bool, persistance: int) -> None:
387384
"""The configuration of alerts raised by the sensor
388385
389386
:param enable: Whether the interrupt output is enabled
@@ -444,7 +441,7 @@ def window_factor(self) -> float:
444441
return self._window_factor
445442

446443
@window_factor.setter
447-
def window_factor(self, factor: float = 1):
444+
def window_factor(self, factor: float = 1) -> None:
448445
if factor < 1:
449446
raise ValueError(
450447
"window transmission factor must be a value of 1.0 or greater"

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
Adafruit-Blinka
66
adafruit-circuitpython-register
77
adafruit-circuitpython-busdevice
8-
typing-extensions~=4.0

0 commit comments

Comments
 (0)