Skip to content

Commit a207fb9

Browse files
committed
🎨 Use Enum for ALLOWED_STATES
1 parent a4e9edd commit a207fb9

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy