Skip to content

Commit 9e75c3e

Browse files
committed
refactor(assets): Optimize list_microgrid_electrical_component_connections method
This commit refactors the `list_microgrid_electrical_component_connections` method in the `AssetsApiClient` class to use `map` and `filter` for improved readability and performance. The method now filters out any falsey connections before mapping them to the appropriate component connection objects. Signed-off-by: eduardiazf <[email protected]>
1 parent 950965d commit 9e75c3e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/frequenz/client/assets/_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ async def list_microgrid_electrical_component_connections(
175175
method_name="ListMicrogridElectricalComponentConnections",
176176
)
177177

178-
return [
179-
component_connection_from_proto(connection)
180-
for connection in response.connections
181-
]
178+
return list(
179+
map(
180+
component_connection_from_proto,
181+
filter(bool, response.connections),
182+
)
183+
)

0 commit comments

Comments
 (0)