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

Make enums inherit from str and enum.Enum in ModelGenerator.render #637

Open
alxdrcirilo opened this issue May 23, 2024 · 1 comment
Open

Comments

@alxdrcirilo
Copy link

Is your feature request related to a problem? Please describe.
Generating Python classes from an avro schema using dataclasses-avroschema.ModelGenerator.render method with the model_type argument set to ModelType.AVRODANTIC will render a Python class with the enum.

For example:

class SomeEnum(enum.Enum):
    ...

Describe the solution you'd like
Since enums in avro are always strings, it would be nice to have the aforementioned method render.

If we take the previous example:

class SomeEnum(str, enum.Enum):
    ...

Describe alternatives you've considered
NA

Additional context
NA

@marcosschroh
Copy link
Owner

Yes, it makes sense. We should do it regardless the ModelType that is used.

@alxdrcirilo alxdrcirilo changed the title Make enums inherit from str and enum.Enum in ModelGenerator when rendering to ModelType.AVRODANTIC Make enums inherit from str and enum.Enum in ModelGenerator.render May 27, 2024
alxdrcirilo added a commit to alxdrcirilo/dataclasses-avroschema that referenced this issue May 27, 2024
alxdrcirilo added a commit to alxdrcirilo/dataclasses-avroschema that referenced this issue Jun 3, 2024
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

No branches or pull requests

2 participants