Skip to content

Remove/deprecate remainain instances of _with_issues functions - #272

Merged
llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:rm-issues
Aug 20, 2026
Merged

Remove/deprecate remainain instances of _with_issues functions#272
llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:rm-issues

Conversation

@llucax

@llucax llucax commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR deprecates and removes all the remaining instances of _with_issues() functions, that should now have an anternative that reports issues via the type system. This should finalize #239 for the v0.4.1 release.

llucax added 4 commits August 19, 2026 14:15
The electrical component connection converters are new in this development
cycle (the `_electrical_component_connection.py` module did not exist in
v0.4.0), so the `_with_issues` flavor was never released and can be removed
outright rather than deprecated.

Its only diagnostic — a "self-referencing connection" major issue — is
already encoded in the return type: a connection whose source and
destination match is returned as a
`SelfReferencingElectricalComponentConnection`. Routing the same fact
through a side-channel `major_issues`/`minor_issues` string list (and the
wrapper's warning/debug logging built from it) was therefore redundant.

Fold the conversion directly into `electrical_component_connection_from_proto`,
which now reports malformed input purely via the returned type, and drop the
issue arrays, the logging and the now-unused `logging` import.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The `ElectricalComponent` message-level converters are new in this
development cycle (v0.4.0 shipped only the enum converters in this module),
so the `_with_issues` flavor was never released and can be removed outright
rather than deprecated.

Every diagnostic it collected is already encoded in the returned type:

  * an unspecified category  -> `UnspecifiedElectricalComponent`
  * an unrecognized category -> `UnrecognizedElectricalComponent`
  * a category that disagrees with its carried info ->
    `MismatchedCategoryElectricalComponent`
  * an unspecified/unrecognized battery, EV charger or inverter type ->
    the matching `Unrecognized*` class (preserving the raw wire `type`)

Routing the same facts through a side-channel `major_issues`/`minor_issues`
string list (and the wrapper's warning/debug logging built from it) was
therefore redundant.

Fold the conversion into the plain `electrical_component_from_proto`, which
now reports malformed input purely via the returned type, and simplify the
private helper to `_electrical_component_base_from_proto` (no issue
arguments). The now-unused `logging` import and module logger go with them.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
The `MetricSample` and `MetricConnection` converters only shipped in the
`_with_issues` flavor, which reports an unspecified/unrecognized metric or
category through a side-channel `major_issues`/`minor_issues` string list.
That information is already carried by the returned type, though:
`MetricSample.metric` and `MetricConnection.category` are `... | int` (the
raw `0` for unspecified, the raw value for unrecognized) and bounds are a
`BoundsSet | InvalidBoundsSet`, so the issue list is redundant.

Add plain `metric_sample_from_proto` and `metric_connection_from_proto`
converters that drop the issue arrays and let callers read validity off the
returned object (or the raising `get_*()` accessors). `RELEASE_NOTES.md`
already referred to `metric_sample_from_proto` as the dataclass-level
converter; this makes it real.

The released `_with_issues` variants are intentionally left untouched here;
they are deprecated in a follow-up commit.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
`metric_sample_from_proto_with_issues` and
`metric_connection_from_proto_with_issues` were released in v0.4.0, so they
are deprecated rather than removed, in favour of the type-system
`metric_sample_from_proto` / `metric_connection_from_proto` added in the
previous commit. Add the `@deprecated` decorator and a `Warning: Deprecated`
docstring admonition to both, matching the existing
`bounds_from_proto_with_issues` deprecation.

`metric_sample_from_proto_with_issues` still delegates to the now-deprecated
`metric_connection_from_proto_with_issues` to preserve its released
issue-collecting behaviour, so wrap that internal call in a
`warnings.catch_warnings()` block: calling the sample converter then emits
only its own `DeprecationWarning`, not the connection one as well.

Update the existing tests to expect the deprecation via
`pytest.deprecated_call`; the raw-int-0 / no-enum-warning guarantees now live
on the new converters' tests.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax requested a review from a team as a code owner August 19, 2026 12:18
@llucax
llucax requested review from florian-wagner-frequenz and removed request for a team August 19, 2026 12:18
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions labels Aug 19, 2026
@llucax llucax self-assigned this Aug 19, 2026
@llucax
llucax enabled auto-merge August 19, 2026 13:21
@llucax llucax added the type:enhancement New feature or enhancement visitble to users label Aug 19, 2026
@llucax
llucax added this pull request to the merge queue Aug 20, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 74a0072 Aug 20, 2026
13 checks passed
@llucax
llucax deleted the rm-issues branch August 20, 2026 08:56
@llucax llucax linked an issue Aug 21, 2026 that may be closed by this pull request
@llucax llucax added this to the v0.4.1 milestone Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests type:enhancement New feature or enhancement visitble to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove _with_issue() proto conversion and make errors more explicit

2 participants