You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecate `EnergyMarketCodeType.UNSPECIFIED`, `Metric.UNSPECIFIED` and
`MetricConnectionCategory.UNSPECIFIED` and add new safe accessor methods
to retrieve the valid enum values or raise an exception:
- `DeliveryArea.get_code_type()`
- `MetricConnection.get_category()`
- `MetricSample.get_metric()`
The `UNSPECIFIED` value is now stored as a low-level `0` integer, so
users can still access it directly if needed, but regular use will raise
an exception if trying to use an unspecified or unrecognized value. This
should lead to much simpler happy path, while still allowing for the
possibility of handling unspecified values in a controlled manner and
making rare and error conditions more explicit.
The `ElectricalComponentCategory` and `XxxType` enums are not affected
by this change, as they do not have an `UNSPECIFIED` value, but will be
completely removed in the future.
Part of #223.
When loading these types from protobuf using dataclass-level converters (e.g., `delivery_area_from_proto`, `metric_sample_from_proto`), the low-level fields (`code_type`, `category`, `metric`) now store the raw integer `0` for unspecified values instead of the deprecated member. Unspecified values should be rare errors, so it is better to expose them only via the low-level interface.
16
+
17
+
Lower-level enum-level converters still return the deprecated member.
18
+
19
+
Users are encouraged to switch from direct field access to the new `get_*()` methods (see New Features), which provide a safer way to handle unspecified or unrecognized values.
10
20
11
21
## New Features
12
22
23
+
* Added new exceptions:
24
+
25
+
*`frequenz.client.common.ClientCommonError` as a base exception for the package.
26
+
*`frequenz.client.common.UnspecifiedValueError` for unspecified values (raw `0` or the deprecated member).
27
+
*`frequenz.client.common.UnrecognizedValueError` for enum members not yet recognized by the library. Carries the raw integer value in its `value` attribute.
28
+
29
+
* Added safe convenience getters that raise the new exceptions for unspecified or unrecognized values:
* Added a new `frequenz.client.common.types.Lifetime` type together with the `frequenz.client.common.types.proto.v1alpha8.lifetime_from_proto` conversion function.
36
+
14
37
* Added a new `frequenz.client.common.types.Location` type together with the `frequenz.client.common.types.proto.v1alpha8.location_from_proto` conversion function.
38
+
15
39
* Added a new `frequenz.client.common.microgrid.Microgrid` type, together with the `frequenz.client.common.microgrid.proto.v1alpha8.microgrid_from_proto` conversion function.
16
-
* Added a new `frequenz.client.common.ClientCommonError` base exception and `UnspecifiedValueError` at the package root.
40
+
17
41
* Added a new `frequenz.client.common.microgrid.electrical_components` package, featuring a `ElectricalComponent` class hierarchy and its families (battery, inverter, EV charger, etc.), and `ElectricalComponentConnection`, including `v1alpha8` proto conversion functions.
18
42
* Added a new `frequenz.client.common.microgrid.Microgrid` type with a raising `is_active()` method, together with the `frequenz.client.common.microgrid.proto.v1alpha8.microgrid_from_proto` conversion function.
0 commit comments