You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
from typing import Optional
@dataclass
class Error:
message: Optional[str] = None
class InternalServerErrorCode(Enum):
INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR'
class ServiceUnavailableErrorCode(Enum):
SERVICE_UNAVAILABLE = 'SERVICE_UNAVAILABLE'
@dataclass
class InternalServerError(Error):
code: InternalServerErrorCode
@dataclass
class ServiceUnavailableError(Error):
code: ServiceUnavailableErrorCode
Which is inconsistent and will lead to the following error:
Describe the bug
Generated classes create code that errors with TypeError: non-default argument 'XYZ' follows default argument.
To Reproduce
Used commandline:
Generated code:
Which is inconsistent and will lead to the following error:
This can be solved by adding kw_only argument as to the dataclass annotation as follows: @DataClass(kw_only=True) as described in:
https://stackoverflow.com/questions/69711886/python-dataclasses-inheritance-and-default-values
The text was updated successfully, but these errors were encountered: