Skip to content

Commit

Permalink
Use custom StrEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
chanhosuh committed Oct 30, 2023
1 parent 45b86a5 commit 1b2381f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions curvesim/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
from enum import Enum


class Chain(str, Enum):
class StrEnum(str, Enum):
def __str__(self):
"""
Regular Enum's __str__ is the name, rather than the value,
e.g.
>>> str(Chain.MAINNET)
'Chain.MAINNET'
so we need to explicit use the value.
This is not necessary in Python 3.11 or above, where the
builtin `StrEnum` has this behavior.
"""
return str.__str__(self)


class Chain(StrEnum):
MAINNET = "mainnet"
ARBITRUM = "arbitrum"
OPTIMISM = "optimism"
Expand All @@ -11,6 +28,6 @@ class Chain(str, Enum):
XDAI = "xdai"


class Env(str, Enum):
class Env(StrEnum):
PROD = "prod"
STAGING = "staging"

0 comments on commit 1b2381f

Please sign in to comment.