Closed
Description
It looks like if you pass an Enum class directly to a generic that wants an iterable (eg list
, frozenset
) it will forget which type of Enum you have. However if you make a no-op iterable out of it first, the enum type is preserved:
from enum import Enum
class Colors(Enum):
RED = 0
BLUE = 1
reveal_type(frozenset(c for c in Colors)) # <-- Is `frozenset[Colors*]`
reveal_type(frozenset(Colors)) # <-- Is `frozenset[Enum*]`
The last line here should have type frozenset[Colors*]
rather than frozenset[Enum*]