Skip to content

Commit f95d838

Browse files
committed
refactor(assets): Update list_microgrid_electrical_component_connections
Updates list_microgrid_electrical_component_connections to accept Iterable[int] for source/destination component IDs. Signed-off-by: eduardiazf <[email protected]>
1 parent 2b9dac4 commit f95d838

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/frequenz/client/assets/_client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from __future__ import annotations
1111

12+
from collections.abc import Iterable
13+
1214
from frequenz.api.assets.v1 import assets_pb2, assets_pb2_grpc
1315
from frequenz.client.base import channel
1416
from frequenz.client.base.client import BaseApiClient, call_stub_method
@@ -141,8 +143,8 @@ async def list_microgrid_electrical_components(
141143
async def list_microgrid_electrical_component_connections(
142144
self,
143145
microgrid_id: int,
144-
source_component_ids: list[int] | None = None,
145-
destination_component_ids: list[int] | None = None,
146+
source_component_ids: Iterable[int] = (),
147+
destination_component_ids: Iterable[int] = (),
146148
) -> list[ComponentConnection | None]:
147149
"""
148150
Get the electrical component connections of a microgrid.
@@ -160,14 +162,10 @@ async def list_microgrid_electrical_component_connections(
160162
"""
161163
request = assets_pb2.ListMicrogridElectricalComponentConnectionsRequest(
162164
microgrid_id=microgrid_id,
165+
source_component_ids=source_component_ids,
166+
destination_component_ids=destination_component_ids,
163167
)
164168

165-
if source_component_ids:
166-
request.source_component_ids.extend(source_component_ids)
167-
168-
if destination_component_ids:
169-
request.destination_component_ids.extend(destination_component_ids)
170-
171169
response = await call_stub_method(
172170
self,
173171
lambda: self.stub.ListMicrogridElectricalComponentConnections(

0 commit comments

Comments
 (0)