What's needed?
The list_microgrid_electrical_components method returns list[ElectricalComponent]. When there are errors in the proto conversion, they are raised:
|
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:
|
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
What's needed?
The
list_microgrid_electrical_componentsmethod returnslist[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
The
list_microgrid_electrical_component_connectionsmethod on the other hand returnslist[ComponentConnection | None]. When there's a protobuf conversion error, we get aNone:frequenz-client-assets-python/src/frequenz/client/assets/_client.py
Lines 145 to 150 in cd345b3
They should have consistent behaviour.
Proposed solution
The idiomatic Python way for handling errors is through exceptions. So
list_microgrid_electrical_component_connectionsshould stop sendingNonevalues and raise exceptions instead.Use cases
No response
Alternatives and workarounds
No response
Additional context
No response