Check that cast is not redundant [redundant-cast]
If you use —warn-redundant-casts
, mypy will generate an error if the sourcetype of a cast is the same as the target type.
Example:
- # mypy: warn-redundant-casts
- from typing import cast
- Count = int
- def example(x: Count) -> int:
- # Error: Redundant cast to "int" [redundant-cast]
- return cast(int, x)