https://mypy-play.net/?mypy=1.17.0&python=3.12&gist=25e4031ca17d70626baee7a468ac4d9f
defternary_list[T, S](x: list[T], y: list[S]) ->None:
a=xif""elseyreveal_type(a) # list[T] | list[S] ✅defternary_list2() ->None:
a=list[int]() if""elselist[str]()
reveal_type(a) # list[int] | list[str] ✅defternary_list_literal() ->None:
a= [1] if""else ["a"] # E: List item 0 has incompatible type "str"reveal_type(a) # list[int] ???
I would have expected list[int] | list[str] in the literal case as well.
https://mypy-play.net/?mypy=1.17.0&python=3.12&gist=25e4031ca17d70626baee7a468ac4d9f
I would have expected
list[int] | list[str]in the literal case as well.