-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
reason: inexpressibleClosed, because this can't be expressed within the current type systemClosed, because this can't be expressed within the current type system
Description
from enum import StrEnum, auto
from typing import reveal_type
class Test(StrEnum):
test = auto()
print(type(Test.test.value))
def func(x: Test):
print(reveal_type(x.value))
func(Test.test)On 3.11 this returns:
❯ python test.py
<class 'str'>
Runtime type is 'str'
testHowever, both pyright and mypy reveal the type as being int because of:
Lines 289 to 290 in 201940c
| # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() | |
| class auto(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.
Metadata
Metadata
Assignees
Labels
reason: inexpressibleClosed, because this can't be expressed within the current type systemClosed, because this can't be expressed within the current type system