Skip to content

Make Microgrid/ElectricalComponent .name non-optional#238

Open
llucax wants to merge 4 commits into
frequenz-floss:v0.x.xfrom
llucax:name-str
Open

Make Microgrid/ElectricalComponent .name non-optional#238
llucax wants to merge 4 commits into
frequenz-floss:v0.x.xfrom
llucax:name-str

Conversation

@llucax

@llucax llucax commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Both Microgrid.name and ElectricalComponent.name were typed str | None, forcing consumers to distinguish between "no name" and an empty name — semantically identical states, since the underlying protobuf name fields default to "" when unset.

Change both to str and represent the absence of a name as "" (matching the protobuf default). As a consequence, the name is empty minor issue reported by microgrid_from_proto and _electrical_component_base_from_proto_with_issues is no longer meaningful — being unnamed is now valid rather than an issue worth flagging — so it is removed.

Part of #239.

@llucax llucax requested a review from a team as a code owner July 6, 2026 12:52
@llucax llucax requested review from ela-kotulska-frequenz and removed request for a team July 6, 2026 12:52
@github-actions github-actions Bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:microgrid Affects the microgrid protobuf definitions labels Jul 6, 2026
@llucax llucax changed the title Make Microgrid.name and ElectricalComponent.name non-optional Make Microgrid's and ElectricalComponent's name non-optional Jul 6, 2026
@llucax llucax changed the title Make Microgrid's and ElectricalComponent's name non-optional Make Microgrid/ElectricalComponent .name non-optional Jul 6, 2026
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Jul 6, 2026
@llucax llucax self-assigned this Jul 6, 2026
llucax added 4 commits July 7, 2026 15:28
Change the type of `Microgrid.name` from `str | None` to `str`.
Represent the absence of a name as `""` (matching the protobuf
default) rather than `None`, so consumers don't have to distinguish
between "no name" and "empty name" — the two are semantically
identical.

`microgrid_from_proto` now assigns `message.name` directly since
protobuf string fields default to `""` when unset.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Now that `Microgrid.name` is `str` and represents the absence of a
name as `""`, having no name is not an issue worth flagging.

Drop the `minor_issues` bookkeeping in `microgrid_from_proto` (it
was only used for the empty-name case) and the accompanying DEBUG
log.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Change the type of `ElectricalComponent.name` from `str | None` to
`str`. Represent the absence of a name as `""` (matching the protobuf
default) rather than `None`, so consumers don't have to distinguish
between "no name" and "empty name" — the two are semantically
identical.

The intermediate `_ElectricalComponentBaseData.name` and the proto
conversion helpers are updated to match; tests that constructed
concrete components without a name now pass `name=""` explicitly.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Now that `ElectricalComponent.name` is `str` and represents the
absence of a name as `""`, having no name is not an issue worth
flagging.

Drop the `name is empty` minor issue in
`_electrical_component_base_from_proto_with_issues` and inline
`message.name` in the resulting `_ElectricalComponentBaseData`.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:microgrid Affects the microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant