-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I have this code:
class E(Enum):
a = "a"
b = "b"
class Blah(models.Model):
e = EnumField(E, null=False)
def test(b: Blah) -> int:
reveal_type(b.e)
if b.e is E.a:
return 1
else:
assert_never(b.e)
def mkb() -> Blah:
return Blah.objects.create(e=E.a)
when I run mypy over it:
- the
reveal_type
call printsRevealed type is "django_enum.fields.EnumField[Any]"
- there is no complaint about
assert_never
, even though not all cases are handled - the
Blah.objects.create
call complains:error: Incompatible type for "e" of "Blah" (got "E", expected "str | int | Combinable") [misc]
this is mypy 1.15.0, django-stubs 5.1.3
The same thing happens if E
inherits from TextChoices
, fwiw
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request