fromenumimportStrEnum, autofromtypingimportreveal_typeclassTest(StrEnum):
test=auto()
print(type(Test.test.value))
deffunc(x: Test):
print(reveal_type(x.value))
func(Test.test)
On 3.11 this returns:
❯ python test.py<class 'str'>Runtime type is 'str'test
However, both pyright and mypy reveal the type as being int because of:
| # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() |
| classauto(IntFlag): |
This was introduced all the way back in #1331.
Well it might be "mostly" correct, with StrEnum this is clearly false and leads to cases where we couldn't use StrEnum without adding type: ignores anyway.
I don't really know what the appropriate fix is so I sadly can't contribute one.
On
3.11this returns:However, both
pyrightandmypyreveal the type as beingintbecause of:typeshed/stdlib/enum.pyi
Lines 289 to 290 in 201940c
This was introduced all the way back in #1331.
Well it might be "mostly" correct, with
StrEnumthis is clearly false and leads to cases where we couldn't useStrEnumwithout addingtype: ignoresanyway.I don't really know what the appropriate fix is so I sadly can't contribute one.