callables_subtyping error

Callable subtyping violations (covariance / contravariance)

Callable types are covariant with respect to return types and contravariant with respect to parameter types. When a Callable[T, R]-annotated variable is assigned a value whose type is Callable[S, Q], the assignment is only valid when:

- Q is a subtype of R (return type — covariant) - T is a subtype of S (parameter type — contravariant, i.e. the source must accept everything the target accepts, which means a broader type)

def func(
    cb1: Callable[[float], int],
    cb3: Callable[[int], int],
) -> None:
    f6: Callable[[float], float] = cb3  # E — int param is not supertype of float
    f8: Callable[[int], int] = cb2      # E — float return is not subtype of int

This rule specifically handles assignments inside function bodies where the RHS is a parameter whose type is already known to be a Callable.

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial callables_subtyping down per-file or per-path from your editor or pyproject.toml, or fix the code so it type-checks. See the Type System rules and the complete diagnostic reference.

Canonical URL: https://www.basilisk-python.dev/errors/callables_subtyping