Closed
Description
In this example, the behavior changed in #11962:
from enum import IntEnum
from typing import Any
class C(IntEnum):
X = 0
Y = 1
Z = 2
def f1(c: C) -> None:
x = {'x': c.value}
# Old: builtins.dict[builtins.str*, builtins.int*]
# New: builtins.dict[builtins.str*, Union[builtins.int, builtins.int, builtins.int]]
reveal_type(x)
def f2(c: C, a: Any) -> None:
x = {'x': c.value, 'y': a}
# Old: builtins.dict[builtins.str*, Any]
# New: builtins.dict[builtins.str*, Union[Any, builtins.int, builtins.int, builtins.int]]
reveal_type(x)
These seem like regressions. The duplicate int types in unions seem like an unrelated issue that #11962 exposed. In some cases it can result in unions with dozens of items, which look pretty confusing. I'm not sure yet whether the second change is an issue with #11962 or something else.