Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueEnum now in Python std lib? #472

Open
janosh opened this issue Nov 3, 2023 · 0 comments
Open

ValueEnum now in Python std lib? #472

janosh opened this issue Nov 3, 2023 · 0 comments
Labels
question Further information is requested

Comments

@janosh
Copy link
Member

janosh commented Nov 3, 2023

Is the ValueEnum the same thing as StrEnum added into Python 3.11+ std lib?

class ValueEnum(Enum):
"""Enum that serializes to string as the value and can be compared against a str."""
def __str__(self):
"""Get a string representation of the enum."""
return str(self.value)
def __eq__(self, other):
"""Compare to another enum for equality."""
if type(self) == type(other) and self.value == other.value:
return True

If so we could replace with ValueEnum with StrEnum in ~2 years. Feel free to leave a note in the code (or not) and close this issue.

@janosh janosh added the question Further information is requested label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant