Skip to content

Improve API consistency #57

@shsms

Description

@shsms

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:❓We need to figure out which part is affectedpriority:❓We need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions