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

Fix enums including whitespace #69

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chrispahm
Copy link

The current class-based enum definition yields invalid Python syntax when enums include whitespace

class EnumWithSpaces(str, Enum):
    another value = 'another value'
    some value = 'some value'

This PR changes the output of enums using the functional API that allows us to specify the member names using tuple lists or dicts. This way we can use names with spaces:

EnumWithSpaces = Enum(
    value='EnumWithSpaces',
    names=[
        ('another value', 'another value'),
        ('some value', 'some value')
    ]
)

All tests are passing and updated to the new enum syntax.

Fixes #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace in enums creates invalid syntax
1 participant