Skip to content

Commit f73514c

Browse files
author
James Souter
committed
typing
1 parent ecdc15f commit f73514c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_attribute.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ async def get(self, uri: str):
144144
elif uri == "status/float_parameter":
145145
value = self._float_value
146146
self._float_value += 1
147+
else:
148+
raise RuntimeError()
147149
return value
148150

149151
async def set(self, uri: str, value: float | int):
@@ -174,15 +176,16 @@ async def update(
174176
attr: AttrR[NumberT, DemoParameterAttributeIORef],
175177
):
176178
value = await attr.io_ref.connection.get(attr.io_ref.uri)
177-
await attr.set(value)
179+
await attr.set(value) # type: ignore
178180

179181
async def send(
180182
self,
181183
attr: AttrW[NumberT, DemoParameterAttributeIORef],
182184
value: NumberT,
183185
) -> None:
184186
await attr.io_ref.connection.set(attr.io_ref.uri, value)
185-
await self.update(attr)
187+
if isinstance(attr, AttrRW):
188+
await self.update(attr)
186189

187190
class DemoParameterController(Controller):
188191
ro_int_parameter: AttrR
@@ -196,6 +199,7 @@ async def initialise(self):
196199
example_introspection_response = await self._connection.get(
197200
"config/introspect_api"
198201
)
202+
assert isinstance(example_introspection_response, list)
199203
for parameter_response in example_introspection_response:
200204
try:
201205
ro = parameter_response["read_only"]
@@ -250,7 +254,9 @@ class MyController(Controller):
250254

251255
class SimpleAttributeIO(AttributeIO[T, AttributeIORef]):
252256
async def update(self, attr):
253-
await attr.set(100)
257+
match attr:
258+
case AttrR(datatype=Int()):
259+
await attr.set(100)
254260

255261
with pytest.raises(
256262
RuntimeError, match="More than one AttributeIO class handles AttributeIORef"

0 commit comments

Comments
 (0)