Back to Intellij Community

PyUnnecessaryCastInspection

python/python-psi-impl/resources/inspectionDescriptions/PyUnnecessaryCastInspection.html

2025.3-rc-2203 B
Original Source

Reports unnecessary calls to typing.cast when the expression already has the specified target type.

Example:

from typing import cast

a: int
b = cast(int, a) # Unnecessary, a is already int