no-isinstance-type-error-guard
Declare the accepted type instead of raising TypeError after an isinstance check.
Why
A runtime type guard that raises TypeError means the signature admits values the code rejects; the contract is enforced by hand where type checkers cannot see it.
Fix
Narrow the parameter, attribute or return type so callers cannot pass the rejected value, parse untrusted input once at the boundary into a typed model, and end exhaustive type dispatch with assert_never.
Examples
def port(value: object) -> int: if not isinstance(value, int): raise TypeError(value) return valuedef port(value: int) -> int: return value