Skip to content

Commit f4f8d67

Browse files
committed
🎨 Use Enum for ALLOWED_STATES
1 parent 1994136 commit f4f8d67

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎cherry_picker/cherry_picker/cherry_picker.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55
import collections
6+
import enum
67
import os
78
import subprocess
89
import webbrowser
@@ -40,9 +41,9 @@ class InvalidRepoException(Exception):
4041

4142
class CherryPicker:
4243

43-
ALLOWED_STATES = (
44-
'BACKPORT_PAUSED',
45-
'UNSET',
44+
ALLOWED_STATES = enum.Enum(
45+
'Allowed states',
46+
'BACKPORT_PAUSED UNSET',
4647
)
4748
"""The list of states expected at the start of the app."""
4849

@@ -435,12 +436,13 @@ def get_state_and_verify(self):
435436
cherry_picker would have stored in the config.
436437
"""
437438
state = get_state()
438-
if state not in self.ALLOWED_STATES:
439+
if state not in self.ALLOWED_STATES.__members__:
439440
raise ValueError(
440441
f'Run state cherry-picker.state={state} in Git config '
441442
'is not known.\nPerhaps it has been set by a newer '
442443
'version of cherry-picker. Try upgrading.\n'
443-
f'Valid states are: {", ".join(self.ALLOWED_STATES)}. '
444+
'Valid states are: '
445+
f'{", ".join(self.ALLOWED_STATES.__members__.keys())}. '
444446
'If this looks suspicious, raise an issue at '
445447
'https://github.com/python/core-workflow/issues/new.\n'
446448
'As the last resort you can reset the runtime state '

0 commit comments

Comments
 (0)