Skip to content

Fix and improve docstrings#215

Merged
llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:fix-docstrings
Jun 16, 2026
Merged

Fix and improve docstrings#215
llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:fix-docstrings

Conversation

@llucax

@llucax llucax commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Part of #203.

llucax added 4 commits June 16, 2026 12:36
Several category docstrings had drifted from the protobuf documentation and
were semantically wrong, too narrow, or too broad:

- `INVERTER` described an inverter as "an electricity generator", which is
  wrong; it converts DC to AC power and vice versa.
- `UNSPECIFIED` described an "unknown" category with error-handling advice;
  the proto means the sender did not specify a category and it should not be
  used (unknown/forward-incompatible categories are handled separately by
  `UnrecognizedElectricalComponent`).
- `BATTERY` said "used by inverters", implying a fixed topology; it is a
  battery energy storage system on its own.
- `BREAKER` said "a relay"; a circuit breaker adds protection semantics.
- `CHP` restricted the source to combustion, which the proto does not.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The proto describes this state as the component being *temporarily*
unavailable for operation. The wrapper dropped "temporarily", which could
mislead users into reading the state as permanent.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Several diagnostic-code docstrings had dropped important context from the
protobuf documentation: the grid and inverter codes mean the component is
*inoperable*, not merely that a value is out of range; the threshold codes
omitted the manufacturer/user-defined threshold context;
`RELAY_CYCLE_LIMIT_REACHED` is about the battery's DC contactor or relays
reaching end of life; and `GRID_DISCONNECTED`/`GRID_VOLTAGE_IMBALANCE`/
`GRID_ABNORMAL`/`PLAUSIBILITY_ERROR` lost their qualifying conditions.

`PROTECTIVE_SHUTDOWN` is intentionally left as-is: the proto comment for it is
a copy-paste duplicate of `HARDWARE_FAULT` ("inoperable due to its hardware
being faulty"), so the existing, more accurate wrapper wording is kept rather
than introducing a misleading duplicate.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Three small docstring/comment issues in the metrics sample module:

- `MetricSample.connection` was documented as an "electrical connection within
  the component", but `MetricSample` is also used by sensor telemetry and
  `MetricConnectionCategory` includes ambient, cabinet, heatsink, and
  transformer connections. Use neutral wording.
- The `MetricSample` class docstring dropped "or derived"; the value is either
  measured or derived at a particular time.
- Remove the stale comment claiming `value` is limited to `float`; the
  annotation is already `float | AggregatedMetricValue | None` and the
  converter handles aggregated metrics.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax llucax requested a review from a team as a code owner June 16, 2026 10:36
@llucax llucax requested review from daniel-zullo-frequenz and removed request for a team June 16, 2026 10:36
@github-actions github-actions Bot added part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions labels Jun 16, 2026
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Jun 16, 2026
@llucax llucax added this to the v0.4.1 milestone Jun 16, 2026
@llucax llucax enabled auto-merge June 16, 2026 10:39
@llucax llucax added this pull request to the merge queue Jun 16, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit c20db72 Jun 16, 2026
12 of 13 checks passed
@llucax llucax deleted the fix-docstrings branch June 16, 2026 10:53
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:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants