no-contradictory-type-guard
Type guards must agree with the predicate they return.
Why
Callers trust a guard's declared target. An incompatible primitive test or an unconditional result can narrow a value incorrectly. TypeIs can also exclude the target incorrectly in the false branch.
Fix
Align the declared target and runtime test. For an intentional partial predicate, TypeGuard may narrow only the true branch; TypeIs must recognize every target value admitted by its input. Review callers before changing the narrowing contract.
Examples
from typing import TypeGuard
def is_text(value: object) -> TypeGuard[str]: return isinstance(value, int)from typing import TypeGuard
def is_text(value: object) -> TypeGuard[str]: return isinstance(value, str)from typing import TypeGuard
def is_text(value: object) -> TypeGuard[str]: return Truefrom typing import TypeGuard
def is_text(value: object) -> TypeGuard[str]: return Falsefrom typing import TypeIs
class User: pass
def is_user(value: object) -> TypeIs[User]: return Truefrom typing import TypeIs
class User: pass
def is_user(value: object) -> TypeIs[User]: return isinstance(value, User)