37
37
from adafruit_register .i2c_bit import RWBit , ROBit
38
38
39
39
try :
40
- from typing import Optional , Tuple , Type , Union
41
- from typing_extensions import Literal
40
+ from typing import Optional , Tuple , Type
42
41
from busio import I2C
43
42
except ImportError :
44
43
pass
@@ -74,8 +73,8 @@ def __init__(self, register_address, struct_format, bitwidth, length):
74
73
75
74
def __get__ (
76
75
self ,
77
- obj : Optional ["UnalignedStruct " ],
78
- objtype : Optional [Type ["UnalignedStruct " ]] = None ,
76
+ obj : Optional ["LTR390 " ],
77
+ objtype : Optional [Type ["LTR390 " ]] = None ,
79
78
) -> int :
80
79
# read bytes into buffer at correct alignment
81
80
raw_value = unpack_from (self .format , self .buffer , offset = 1 )[0 ]
@@ -92,7 +91,7 @@ def __get__(
92
91
raw_value = unpack_from (self .format , self .buffer , offset = 1 )[0 ]
93
92
return raw_value >> 8
94
93
95
- def __set__ (self , obj : Optional ["UnalignedStruct " ], value : int ) -> None :
94
+ def __set__ (self , obj : Optional ["LTR390 " ], value : int ) -> None :
96
95
pack_into (self .format , self .buffer , 1 , value )
97
96
with obj .i2c_device as i2c :
98
97
i2c .write (self .buffer )
@@ -104,7 +103,7 @@ class CV:
104
103
@classmethod
105
104
def add_values (
106
105
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 ]],
108
107
) -> None :
109
108
"""Add CV values to the class"""
110
109
cls .string = {}
@@ -330,11 +329,11 @@ def _reset(self) -> None:
330
329
i2c .write (bytes ((_THRESH_LOW , 0x00 , 0x00 , 0x00 )))
331
330
332
331
@property
333
- def _mode (self ) -> Literal [ 0 , 1 ] :
332
+ def _mode (self ) -> bool :
334
333
return self ._mode_bit
335
334
336
335
@_mode .setter
337
- def _mode (self , value : Literal [ 0 , 1 ] ) -> None :
336
+ def _mode (self , value : bool ) -> None :
338
337
if not value in [ALS , UV ]:
339
338
raise AttributeError ("Mode must be ALS or UV" )
340
339
if self ._mode_cache != value :
@@ -381,9 +380,7 @@ def resolution(self, value: int):
381
380
raise AttributeError ("resolution must be a Resolution" )
382
381
self ._resolution_bits = value
383
382
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 :
387
384
"""The configuration of alerts raised by the sensor
388
385
389
386
:param enable: Whether the interrupt output is enabled
@@ -444,7 +441,7 @@ def window_factor(self) -> float:
444
441
return self ._window_factor
445
442
446
443
@window_factor .setter
447
- def window_factor (self , factor : float = 1 ):
444
+ def window_factor (self , factor : float = 1 ) -> None :
448
445
if factor < 1 :
449
446
raise ValueError (
450
447
"window transmission factor must be a value of 1.0 or greater"
0 commit comments