Make Microgrid/ElectricalComponent .name non-optional#238
Open
llucax wants to merge 4 commits into
Open
Conversation
Microgrid.name and ElectricalComponent.name non-optionalMicrogrid's and ElectricalComponent's name non-optional
Microgrid's and ElectricalComponent's name non-optionalMicrogrid/ElectricalComponent .name non-optional
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both
Microgrid.nameandElectricalComponent.namewere typedstr | None, forcing consumers to distinguish between "no name" and an empty name — semantically identical states, since the underlying protobufnamefields default to""when unset.Change both to
strand represent the absence of a name as""(matching the protobuf default). As a consequence, thename is emptyminor issue reported bymicrogrid_from_protoand_electrical_component_base_from_proto_with_issuesis no longer meaningful — being unnamed is now valid rather than an issue worth flagging — so it is removed.Part of #239.