Skip to content

Commit 834cc6b

Browse files
committed
Deprecate Event.UNSPECIFIED
Mark `Event.UNSPECIFIED` as deprecated. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
1 parent f40d93c commit 834cc6b

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎src/frequenz/client/common/streaming/_event.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
"""Streaming event type enum."""
55

6-
import enum
6+
from frequenz.core.enum import Enum, deprecated_member, unique
77

88

9-
@enum.unique
10-
class Event(enum.Enum):
9+
@unique
10+
class Event(Enum):
1111
"""A type of streaming event."""
1212

13-
UNSPECIFIED = 0
13+
UNSPECIFIED = deprecated_member(
14+
0,
15+
"Event.UNSPECIFIED is deprecated; use the `int` value `0` "
16+
"instead if you really need to check for this low-level value.",
17+
)
1418
"""Unspecified event type."""
1519

1620
CREATED = 1

‎tests/streaming/proto/v1alpha8/test_event.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ class TestEventParity(EnumParityTest):
2121
name_prefix = "EVENT_"
2222
from_proto = staticmethod(event_from_proto)
2323
to_proto = staticmethod(event_to_proto)
24+
deprecated_members = frozenset({"UNSPECIFIED"})

‎tests/streaming/test_event.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33

44
"""Tests for the `Event` enum domain model."""
55

6+
import pytest
7+
68
from frequenz.client.common.streaming import Event
79

810

911
def test_event_members() -> None:
1012
"""Test that Event has the expected members with correct values."""
1113
assert [m.name for m in Event] == ["UNSPECIFIED", "CREATED", "UPDATED", "DELETED"]
12-
assert Event.UNSPECIFIED.value == 0
14+
with pytest.warns(DeprecationWarning):
15+
assert Event.UNSPECIFIED.value == 0
1316
assert Event.CREATED.value == 1
1417
assert Event.UPDATED.value == 2
1518
assert Event.DELETED.value == 3

0 commit comments

Comments
 (0)