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:

  1. # mypy: warn-redundant-casts
  2.  
  3. from typing import cast
  4.  
  5. Count = int
  6.  
  7. def example(x: Count) -> int:
  8. # Error: Redundant cast to "int" [redundant-cast]
  9. return cast(int, x)