@@ -239,10 +239,14 @@ async def components(self) -> Iterable[Component]:
239
239
try :
240
240
# grpc.aio is missing types and mypy thinks this is not awaitable,
241
241
# but it is
242
- component_list = await self .api .ListComponents (
243
- microgrid_pb .ComponentFilter (),
244
- timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
245
- ) # type: ignore[misc]
242
+ component_list = await cast (
243
+ Awaitable [microgrid_pb .ComponentList ],
244
+ self .api .ListComponents (
245
+ microgrid_pb .ComponentFilter (),
246
+ timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
247
+ ),
248
+ )
249
+
246
250
except grpc .aio .AioRpcError as err :
247
251
msg = f"Failed to list components. Microgrid API: { self .target } . Err: { err .details ()} "
248
252
raise grpc .aio .AioRpcError (
@@ -280,10 +284,13 @@ async def metadata(self) -> Metadata:
280
284
"""
281
285
microgrid_metadata : microgrid_pb .MicrogridMetadata | None = None
282
286
try :
283
- microgrid_metadata = await self .api .GetMicrogridMetadata (
284
- Empty (),
285
- timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
286
- ) # type: ignore[misc]
287
+ microgrid_metadata = await cast (
288
+ Awaitable [microgrid_pb .MicrogridMetadata ],
289
+ self .api .GetMicrogridMetadata (
290
+ Empty (),
291
+ timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
292
+ ),
293
+ )
287
294
except grpc .aio .AioRpcError :
288
295
_logger .exception ("The microgrid metadata is not available." )
289
296
@@ -616,12 +623,15 @@ async def set_power(self, component_id: int, power_w: float) -> None:
616
623
when the api call exceeded timeout
617
624
"""
618
625
try :
619
- await self .api .SetPowerActive (
620
- microgrid_pb .SetPowerActiveParam (
621
- component_id = component_id , power = power_w
626
+ await cast (
627
+ Awaitable [microgrid_pb .SetPowerActiveParam ],
628
+ self .api .SetPowerActive (
629
+ microgrid_pb .SetPowerActiveParam (
630
+ component_id = component_id , power = power_w
631
+ ),
632
+ timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
622
633
),
623
- timeout = int (DEFAULT_GRPC_CALL_TIMEOUT ),
624
- ) # type: ignore[misc]
634
+ )
625
635
except grpc .aio .AioRpcError as err :
626
636
msg = f"Failed to set power. Microgrid API: { self .target } . Err: { err .details ()} "
627
637
raise grpc .aio .AioRpcError (
0 commit comments