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
Is your feature request related to a problem? Please describe.
In most cases, I prefer to use Enums, because it's easier to inspect the enum values than inspecting the literals, as far as I know. So, I usually generate the code using enums. However, for a specific field of a model, I think I need to use a Literal, because this generated class is supposed to be the base class of other classes, which I may manually define, and inheritance doesn't work with enums, as far as I know.
To be concrete, let's say I have a generated class like this
class ALanguage(Enum):
EN = "en"
FR = "fr"
ES = "es"
...
class A
language: ALanguage
...
Now, let's say I define
class BLanguage(Enum):
EN = "en"
class B(A)
language: BLanguage
...
I think this would be wrong inheritance because BLanguage doesn't inherit from ALanguage and even if I changed the code so that BLanguage(ALanguage), I think it's not allowed to redefine the enum options in enum subclasses. I want to restrict the languages in B, and ALanguage should be as general as possible, i.e. contain all possible languages, but I don't think this is possible with Enums because I don't think I can restrict the languages in BLanguage. So, in this specific case, I think Literal would be better, although I am also not sure how inheritance would work with literals, but I think it's allowed to restrict the possible values of the literal in subclasses.
Describe the solution you'd like
A way to specify that we want a specific field of a specific class to use literals instead of enums. For example, using a command-line parameter.
Describe alternatives you've considered
The current alternative is just to manually edit A after it's been generated, but this a pain
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In most cases, I prefer to use Enums, because it's easier to inspect the enum values than inspecting the literals, as far as I know. So, I usually generate the code using enums. However, for a specific field of a model, I think I need to use a Literal, because this generated class is supposed to be the base class of other classes, which I may manually define, and inheritance doesn't work with enums, as far as I know.
To be concrete, let's say I have a generated class like this
Now, let's say I define
I think this would be wrong inheritance because
BLanguage
doesn't inherit fromALanguage
and even if I changed the code so thatBLanguage(ALanguage)
, I think it's not allowed to redefine the enum options in enum subclasses. I want to restrict the languages inB
, andALanguage
should be as general as possible, i.e. contain all possible languages, but I don't think this is possible with Enums because I don't think I can restrict the languages inBLanguage
. So, in this specific case, I think Literal would be better, although I am also not sure how inheritance would work with literals, but I think it's allowed to restrict the possible values of the literal in subclasses.Describe the solution you'd like
A way to specify that we want a specific field of a specific class to use literals instead of enums. For example, using a command-line parameter.
Describe alternatives you've considered
The current alternative is just to manually edit
A
after it's been generated, but this a painThe text was updated successfully, but these errors were encountered: