Skip to content

Commit 16a87c3

Browse files
committed
Make enums unique
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 78548f5 commit 16a87c3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""Module to define the metrics used with the common client."""
55

6-
from enum import Enum
6+
import enum
77
from typing import Self
88

99
# pylint: disable=no-name-in-module
@@ -12,7 +12,8 @@
1212
# pylint: enable=no-name-in-module
1313

1414

15-
class Metric(Enum):
15+
@enum.unique
16+
class Metric(enum.Enum):
1617
"""List of supported metrics.
1718
1819
AC energy metrics information:

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__ import annotations
77

8-
from enum import Enum
8+
import enum
99
from typing import final
1010

1111
# pylint: disable=no-name-in-module
@@ -28,7 +28,8 @@ class ComponentId(BaseId, str_prefix="CID"):
2828
"""A unique identifier for a microgrid component."""
2929

3030

31-
class ComponentCategory(Enum):
31+
@enum.unique
32+
class ComponentCategory(enum.Enum):
3233
"""Possible types of microgrid component."""
3334

3435
UNSPECIFIED = PBComponentCategory.COMPONENT_CATEGORY_UNSPECIFIED
@@ -81,7 +82,8 @@ def to_proto(self) -> PBComponentCategory.ValueType:
8182
return self.value
8283

8384

84-
class ComponentStateCode(Enum):
85+
@enum.unique
86+
class ComponentStateCode(enum.Enum):
8587
"""All possible states of a microgrid component."""
8688

8789
UNSPECIFIED = PBComponentStateCode.COMPONENT_STATE_CODE_UNSPECIFIED
@@ -185,7 +187,8 @@ def to_proto(self) -> PBComponentStateCode.ValueType:
185187
return self.value
186188

187189

188-
class ComponentErrorCode(Enum):
190+
@enum.unique
191+
class ComponentErrorCode(enum.Enum):
189192
"""All possible errors that can occur across all microgrid component categories."""
190193

191194
UNSPECIFIED = PBComponentErrorCode.COMPONENT_ERROR_CODE_UNSPECIFIED

0 commit comments

Comments
 (0)