Describe the bug
When generating code with --use-subclass-enum
, the resulting code is not type-valid according to mypy
To Reproduce
Example schema:
openapi: 3.0.0
components:
schemas:
Unit:
description: Unit of the data shown
type: string
enum:
- COUNT
- ORDINAL
generated code:
class Unit(str, Enum):
count = "COUNT"
ordinal = "ORDINAL"
Used commandline:
$ datamodel-codegen --use-subclass-enum --input schema.yaml > generated_code.py
mypy generated_code.py failes with the "assignment" error:
$ mypy generated_code.py
generated_code.py:14: error: Incompatible types in assignment (expression has type "str", base class "str" defined the type as "Callable[[str, str, Optional[SupportsIndex], Optional[SupportsIndex]], int]") [assignment]
Expected behavior
mypy generated_code.py
should pass
Version:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too