Open
Description
This example started generating an error after #18588, which looks like a regression:
# mypy: warn-redundant-casts
from typing import Literal, cast
Foo = Literal["a", "b"]
class C:
def __init__(self) -> None:
self.x = cast(Foo, "a") # error: Redundant cast to "Literal['a', 'b']"
I haven't looked into this in detail, but it seems possible that we infer a union type for "a"
in a literal union context, which doesn't look right. If this is a correct hypothesis, #18588 wouldn't actually be the root cause, and it would just be exposing a pre-existing issue.
cc @asottile as the author of the PR