Bug Report
See reproducer
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&flags=warn-redundant-casts&gist=f923e1fafbc60a2b7a2fa3c9c3ceb785
from typing import TypeVar, cast
T = TypeVar("T")
def identity(xs: list[T]) -> list[T]:
return xs
def f(xs: list[int]) -> list[int]:
reveal_type(identity(xs))
return cast(list[int], identity(xs)) # --warn-redundant-casts should trigger here
Expected Behavior
warns that the cast is redundant
Actual Behavior
doesn’t warn
Your Environment
- Mypy version used: 2.3.0
- Mypy command-line flags:
--warn-redundant-casts
- Mypy configuration options from
mypy.ini (and other config files): warn-redundant-casts = true
- Python version used: any
Bug Report
See reproducer
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&flags=warn-redundant-casts&gist=f923e1fafbc60a2b7a2fa3c9c3ceb785
Expected Behavior
warns that the cast is redundant
Actual Behavior
doesn’t warn
Your Environment
--warn-redundant-castsmypy.ini(and other config files):warn-redundant-casts = true