From abd264f615ab1bdd41863de8f53dc62569af74ab Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:35:17 -0400 Subject: [PATCH] fix: Add workaround for StrEnum for before/after Python 3.11 --- ocdskit/util.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ocdskit/util.py b/ocdskit/util.py index fcba1f3..34bb6ee 100644 --- a/ocdskit/util.py +++ b/ocdskit/util.py @@ -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): @@ -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'