Skip to content

Commit

Permalink
fix: Add workaround for StrEnum for before/after Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Apr 15, 2024
1 parent 4116b96 commit abd264f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ocdskit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
except ImportError:
jsonlib = json

# https://tomwojcik.com/posts/2023-01-02/python-311-str-enum-breaking-change
try:
from enum import StrEnum
except ImportError:
from enum import Enum

class StrEnum(str, Enum):
pass


# See `grouper` recipe: https://docs.python.org/3/library/itertools.html#recipes
def grouper(iterable, n, fillvalue=None):
Expand Down Expand Up @@ -249,9 +258,7 @@ def detect_format(path, root_path='', reader=open):
)


from enum import Enum

class Format(str, Enum):
class Format(StrEnum):
compiled_release = 'compiled release'
empty_package = 'empty package'
record = 'record'
Expand Down

0 comments on commit abd264f

Please sign in to comment.