[python] PyInvalidCastInspectionTest cleanup

- moved functions to `PyTypeUtil`
- improved naming and documentation
- improved hitbox for unnecessary
- added tests to suites


Merge-request: IJ-MR-174646
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: 4cecc6eb9a22cd8cc4d4019e0ff6f22faebe8cae
This commit is contained in:
Morgan Bartholomew
2025-09-17 08:15:57 +00:00
committed by intellij-monorepo-bot
parent 95e54245ef
commit c2f7a647e3
7 changed files with 68 additions and 33 deletions
@@ -1338,8 +1338,8 @@ INSP.NAME.new.type.new.type.cannot.be.generic=NewType cannot be generic
packaging.could.not.parse.relation=Could not parse relation from: {0}
# PyInvalidCastInspection
INSP.NAME.invalid.cast=Type cast with impossible types
INSP.invalid.cast.message=Cast of type ''{0}'' to type ''{1}'' may be a mistake because no possible value of one is assignable with the other. If this was intentional, cast the expression to ''{2}'' first.
INSP.NAME.invalid.cast=Type cast between unrelated types
INSP.invalid.cast.message=Cast of type ''{0}'' to type ''{1}'' may be a mistake because they are not in the same inheritance hierarchy. If this was intentional, cast the expression to ''{2}'' first.
# Quick fixes for PyInvalidCastInspection
QFIX.add.intermediate.cast=Add cast({0}, ...)