Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@chrispahm
Copy link
Contributor

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

@xnuinside xnuinside merged commit 24d7864 into xnuinside:main Jan 18, 2026
1 check passed
xnuinside added a commit that referenced this pull request Jan 18, 2026
Update test assertions to match the functional Enum format
introduced in PR #69. The new enum template generates:

  Status = Enum(value='Status', names=[...])

Instead of the previous class-based syntax:

  class Status(str, Enum):

Tests updated:
- test_from_pydantic_to_dataclass
- test_pydantic_v2_enums
xnuinside added a commit that referenced this pull request Jan 18, 2026
Update test assertions to match the functional Enum format
introduced in PR #69. The new enum template generates:

  Status = Enum(value='Status', names=[...])

Instead of the previous class-based syntax:

  class Status(str, Enum):

Tests updated:
- test_from_pydantic_to_dataclass
- test_pydantic_v2_enums
@xnuinside
Copy link
Owner

thanks for the pr, sorry for the long delay, have no time at all on open source :/

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

2 participants