Skip to content

Commit 4320e05

Browse files
committed
Deprecate uses of enum's .from_proto()
Recommend using the new `enum_from_proto()` instead. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent eb121d9 commit 4320e05

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/frequenz/client/common/metric/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# pylint: disable=no-name-in-module
1010
from frequenz.api.common.v1.metrics.metric_sample_pb2 import Metric as PBMetric
11+
from typing_extensions import deprecated
1112

1213
# pylint: enable=no-name-in-module
1314

@@ -141,6 +142,7 @@ class Metric(enum.Enum):
141142
SENSOR_IRRADIANCE = PBMetric.METRIC_SENSOR_IRRADIANCE
142143

143144
@classmethod
145+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
144146
def from_proto(cls, metric: PBMetric.ValueType) -> Self:
145147
"""Convert a protobuf Metric value to Metric enum.
146148

src/frequenz/client/common/microgrid/components/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ComponentStateCode as PBComponentStateCode,
2020
)
2121
from frequenz.core.id import BaseId
22+
from typing_extensions import deprecated
2223

2324
# pylint: enable=no-name-in-module
2425

@@ -104,6 +105,7 @@ class ComponentCategory(enum.Enum):
104105
"""A Heating, Ventilation, and Air Conditioning (HVAC) system."""
105106

106107
@classmethod
108+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
107109
def from_proto(
108110
cls, component_category: PBComponentCategory.ValueType
109111
) -> ComponentCategory:
@@ -209,6 +211,7 @@ class ComponentStateCode(enum.Enum):
209211
"""The precharger circuit is closed, allowing full current to flow to the main circuit."""
210212

211213
@classmethod
214+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
212215
def from_proto(
213216
cls, component_state: PBComponentStateCode.ValueType
214217
) -> ComponentStateCode:
@@ -387,6 +390,7 @@ class ComponentErrorCode(enum.Enum):
387390
times."""
388391

389392
@classmethod
393+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
390394
def from_proto(
391395
cls, component_error_code: PBComponentErrorCode.ValueType
392396
) -> ComponentErrorCode:

0 commit comments

Comments
 (0)