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
# Example from https://docs.python.org/3/library/enum.html#functional-apifromenumimportEnumAnimal=Enum('Animal', 'ANT BEE CAT DOG')
# Example from: https://docs.djangoproject.com/en/3.2/ref/models/fields/#enumeration-typesfromdjango.dbimportmodelsclassVehicle(models.TextChoices):
CAR='C'TRUCK='T'JET_SKI='J'
But this raises an error:
# Example from: https://docs.djangoproject.com/en/3.2/ref/models/fields/#enumeration-typesfromdjango.dbimportmodelsMedalType=models.TextChoices('MedalType', 'GOLD SILVER BRONZE')
my_file.py:3: error: No overload variant of "TextChoices" matches argument types "str", "str"
my_file.py:3: note: Possible overload variant:
my_file.py:3: note: def __new__(cls, o: bytes, encoding: str = ..., errors: str = ...) -> TextChoices
my_file.py:3: note: <1 more non-matching overload not shown>
How is that should be
The resulting enum's type should be the same whether you use the normal class based approach or the functional API approach.
System information
OS: linux
python version: 3.9.7
django version: 3.2.8
mypy version: 0.910
django-stubs version: 1.9.0
django-stubs-ext version: 0.3.1
The text was updated successfully, but these errors were encountered:
Bug report
What's wrong
The functional API for Django's Enumeration types doesn't seem to be supported.
These two run fine:
But this raises an error:
How is that should be
The resulting enum's type should be the same whether you use the normal class based approach or the functional API approach.
System information
python
version: 3.9.7django
version: 3.2.8mypy
version: 0.910django-stubs
version: 1.9.0django-stubs-ext
version: 0.3.1The text was updated successfully, but these errors were encountered: