Skip to content

Commit eabcb0f

Browse files
committed
Make types compatible with Python 3.9 and 3.10
Signed-off-by: Joe Friedrichsen <114173023+jfriedri-ni@users.noreply.github.com>
1 parent 9a5ae3c commit eabcb0f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

examples/placeholder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class MyIntEnum(enum.IntEnum):
2121
VALUE30 = 30
2222

2323

24-
class MyStrEnum(enum.StrEnum):
25-
"""Example of a StrEnum enum."""
24+
class MyStrEnum(str, enum.Enum):
25+
"""Example of a mixin string enum."""
2626

2727
VALUE1 = "value1"
2828
VALUE2 = "value2"

tests/types.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
"""Types that exercise conversion to and from protobuf."""
22

33
import enum
4+
import sys
5+
6+
if sys.version_info >= (3, 11):
7+
from enum import StrEnum
8+
else:
9+
10+
class StrEnum(str, enum.Enum):
11+
"""Example of a mixin string enum."""
12+
13+
pass
414

515

616
class MyIntFlags(enum.IntFlag):
@@ -27,7 +37,7 @@ class MixinIntEnum(int, enum.Enum):
2737
VALUE33 = 33
2838

2939

30-
class MyStrEnum(enum.StrEnum):
40+
class MyStrEnum(StrEnum):
3141
"""Example of a StrEnum enum."""
3242

3343
VALUE1 = "value1"

0 commit comments

Comments
 (0)