Closed
Description
There seems to be a problem with enums when inferred and used inside lists. This happens with both mypy 0.540 and mypy 0.520.
Code:
class Magic(Enum):
ISSUER = 1
ISSUER_EXCHANGE = 2
ASSIGNEE = 3
ALL = 3
boo = [c for c in Magic if c not in [Magic.ISSUER]]
boo_explicit: List[Enum] = [c for c in Magic if c not in [Magic.ISSUER]]
spam1: Dict[str, List[Enum]] = {'abc': boo} # Fails with: Dict entry 0 has incompatible type "str": "List[Magic]"; expected "str": "List[Enum]"
spam2: Dict[str, List[Enum]] = {'abc': boo_explicit} # works when typed explicitly
spam3: Dict[str, List[Enum]] = {'abc': [Magic.ISSUER]} # works when done inline
spam4: Dict[str, List[Enum]] = {'abc': [c for c in Magic if c not in [Magic.ISSUER]]} # works when done inline, even with a list comp.
spam5: Dict[str, Enum] = {'abc': Magic.ISSUER} # works Works for single enums.
Let me know what other info you need, or any other steps I should take.
Thanks for all the work on such an awesome project.