Skip to content

Commit 379248f

Browse files
committed
refactor: do not use StrEnum as it only appears in Python 3.11
1 parent 8591960 commit 379248f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

repo2docker/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def _dry_run_changed(self, change):
478478
ignore_file_strategy = Enum(
479479
ExcludesStrategy.values(),
480480
config=True,
481-
default_value=ExcludesStrategy.theirs,
481+
default_value=ExcludesStrategy.THEIRS.value,
482482
help="""
483483
Strategy to use if an extra ignore file is passed:
484484
- merge means that the content of the extra ignore file will be merged
@@ -888,7 +888,9 @@ def build(self):
888888
self.extra_build_kwargs,
889889
platform=self.platform,
890890
extra_ignore_file=self.extra_ignore_file,
891-
ignore_file_strategy=self.ignore_file_strategy,
891+
ignore_file_strategy=ExcludesStrategy(
892+
self.ignore_file_strategy
893+
),
892894
):
893895
if docker_client.string_output:
894896
self.log.info(l, extra=dict(phase=R2dState.BUILDING))

repo2docker/buildpacks/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88
import tarfile
99
import textwrap
10-
from enum import StrEnum, auto
10+
from enum import Enum
1111
from functools import lru_cache
1212

1313
import escapism
@@ -206,10 +206,10 @@
206206
DEFAULT_NB_UID = 1000
207207

208208

209-
class ExcludesStrategy(StrEnum):
210-
theirs = auto()
211-
ours = auto()
212-
merge = auto()
209+
class ExcludesStrategy(Enum):
210+
THEIRS = "theirs"
211+
OURS = "ours"
212+
MERGE = "merge"
213213

214214
@classmethod
215215
def values(cls):
@@ -594,7 +594,7 @@ def build(
594594
extra_build_kwargs,
595595
platform=None,
596596
extra_ignore_file=None,
597-
ignore_file_strategy=ExcludesStrategy.theirs,
597+
ignore_file_strategy=ExcludesStrategy.THEIRS,
598598
):
599599
tarf = io.BytesIO()
600600
tar = tarfile.open(fileobj=tarf, mode="w")
@@ -640,9 +640,9 @@ def _read_excludes(filepath):
640640
excludes.extend(_read_excludes(ignore_file_name))
641641

642642
if extra_ignore_file is not None:
643-
if ignore_file_strategy == ExcludesStrategy.ours:
643+
if ignore_file_strategy == ExcludesStrategy.OURS:
644644
excludes = extra_excludes
645-
elif ignore_file_strategy == ExcludesStrategy.merge:
645+
elif ignore_file_strategy == ExcludesStrategy.MERGE:
646646
excludes.extend(extra_excludes)
647647
else:
648648
# ignore means that if an ignore file exist, its content is used

0 commit comments

Comments
 (0)