Skip to content

Commit ba80f3f

Browse files
Update enum's __str__ (#73)
1 parent 2888361 commit ba80f3f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/betterproto2/enum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def _missing_(cls, value):
1818

1919
def __str__(self):
2020
if not self.name:
21-
return f"{self.__class__.__name__}.~UNKNOWN({self.value})"
22-
return f"{self.__class__.__name__}.{self.name}"
21+
return f"UNKNOWN({self.value})"
22+
return self.name
2323

2424
def __repr__(self):
2525
if not self.name:

tests/test_enum.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class Colour(betterproto2.Enum):
1515
@pytest.mark.parametrize(
1616
"member, str_value",
1717
[
18-
(Colour.RED, "Colour.RED"),
19-
(Colour.GREEN, "Colour.GREEN"),
20-
(Colour.BLUE, "Colour.BLUE"),
21-
(PURPLE, "Colour.~UNKNOWN(4)"),
18+
(Colour.RED, "RED"),
19+
(Colour.GREEN, "GREEN"),
20+
(Colour.BLUE, "BLUE"),
21+
(PURPLE, "UNKNOWN(4)"),
2222
],
2323
)
2424
def test_str(member: Colour, str_value: str) -> None:

0 commit comments

Comments
 (0)