-
Notifications
You must be signed in to change notification settings - Fork 7
Description
What's needed?
The list_microgrid_electrical_components method returns list[ElectricalComponent]. When there are errors in the proto conversion, they are raised:
frequenz-client-assets-python/src/frequenz/client/assets/_client.py
Lines 118 to 120 in cd345b3
| async def list_microgrid_electrical_components( | |
| self, microgrid_id: MicrogridId | |
| ) -> list[ElectricalComponent]: |
The list_microgrid_electrical_component_connections method on the other hand returns list[ComponentConnection | None]. When there's a protobuf conversion error, we get a None:
frequenz-client-assets-python/src/frequenz/client/assets/_client.py
Lines 145 to 150 in cd345b3
| async def list_microgrid_electrical_component_connections( | |
| self, | |
| microgrid_id: MicrogridId, | |
| source_component_ids: Iterable[ElectricalComponentId] = (), | |
| destination_component_ids: Iterable[ElectricalComponentId] = (), | |
| ) -> list[ComponentConnection | None]: |
They should have consistent behaviour.
Proposed solution
The idiomatic Python way for handling errors is through exceptions. So list_microgrid_electrical_component_connections should stop sending None values and raise exceptions instead.
Use cases
No response
Alternatives and workarounds
No response
Additional context
No response