36
36
from adafruit_register .i2c_struct import Struct , UnaryStruct
37
37
38
38
try :
39
- from typing import Optional , Tuple , Type , Union
39
+ from typing import Any , Optional , Tuple , Type , Union
40
40
from busio import I2C , UART
41
41
except ImportError :
42
42
pass
@@ -149,16 +149,18 @@ def __init__(self, register_address: int, struct_format: str, scale: float) -> N
149
149
super ().__init__ (register_address , struct_format )
150
150
self .scale = scale
151
151
152
- def __get__ (self , obj , objtype = None ) -> Tuple [float , float , float ]:
152
+ def __get__ (
153
+ self , obj : Optional ["BNO055_I2C" ], objtype : Optional [Type ["BNO055_I2C" ]] = None
154
+ ) -> Tuple [float , float , float ]:
153
155
result = super ().__get__ (obj , objtype )
154
156
return tuple (self .scale * v for v in result )
155
157
156
- def __set__ (self , obj , value ) -> None :
158
+ def __set__ (self , obj : Optional [ "BNO055_I2C" ] , value : Any ) -> None :
157
159
raise NotImplementedError ()
158
160
159
161
160
162
class _ReadOnlyUnaryStruct (UnaryStruct ): # pylint: disable=too-few-public-methods
161
- def __set__ (self , obj : int , value : str ) -> None :
163
+ def __set__ (self , obj : Optional [ "BNO055_I2C" ] , value : Any ) -> None :
162
164
raise NotImplementedError ()
163
165
164
166
@@ -168,7 +170,7 @@ def __init__(self, register_address: int, struct_format: str, mode: int) -> None
168
170
self .mode = mode
169
171
170
172
def __get__ (
171
- self , obj : Optional ["BNO055 " ], objtype : Optional [Type ["BNO055 " ]] = None
173
+ self , obj : Optional ["BNO055_I2C " ], objtype : Optional [Type ["BNO055_I2C " ]] = None
172
174
) -> Union [int , Tuple [int , int , int ]]:
173
175
last_mode = obj .mode
174
176
obj .mode = self .mode
@@ -178,7 +180,7 @@ def __get__(
178
180
return result [0 ] if isinstance (result , tuple ) and len (result ) == 1 else result
179
181
180
182
def __set__ (
181
- self , obj : Optional ["BNO055 " ], value : Union [int , Tuple [int , int , int ]]
183
+ self , obj : Optional ["BNO055_I2C " ], value : Union [int , Tuple [int , int , int ]]
182
184
) -> None :
183
185
last_mode = obj .mode
184
186
obj .mode = self .mode
0 commit comments