Skip to content

Commit 14555dd

Browse files
committed
adjusted obj and objtype statments for structure classes
1 parent 951aaff commit 14555dd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

adafruit_bno055.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from adafruit_register.i2c_struct import Struct, UnaryStruct
3737

3838
try:
39-
from typing import Optional, Tuple, Type, Union
39+
from typing import Any, Optional, Tuple, Type, Union
4040
from busio import I2C, UART
4141
except ImportError:
4242
pass
@@ -149,16 +149,18 @@ def __init__(self, register_address: int, struct_format: str, scale: float) -> N
149149
super().__init__(register_address, struct_format)
150150
self.scale = scale
151151

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]:
153155
result = super().__get__(obj, objtype)
154156
return tuple(self.scale * v for v in result)
155157

156-
def __set__(self, obj, value) -> None:
158+
def __set__(self, obj: Optional["BNO055_I2C"], value: Any) -> None:
157159
raise NotImplementedError()
158160

159161

160162
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:
162164
raise NotImplementedError()
163165

164166

@@ -168,7 +170,7 @@ def __init__(self, register_address: int, struct_format: str, mode: int) -> None
168170
self.mode = mode
169171

170172
def __get__(
171-
self, obj: Optional["BNO055"], objtype: Optional[Type["BNO055"]] = None
173+
self, obj: Optional["BNO055_I2C"], objtype: Optional[Type["BNO055_I2C"]] = None
172174
) -> Union[int, Tuple[int, int, int]]:
173175
last_mode = obj.mode
174176
obj.mode = self.mode
@@ -178,7 +180,7 @@ def __get__(
178180
return result[0] if isinstance(result, tuple) and len(result) == 1 else result
179181

180182
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]]
182184
) -> None:
183185
last_mode = obj.mode
184186
obj.mode = self.mode

0 commit comments

Comments
 (0)