generics_variance error

Variance incompatibility in base class parameterisation

When a class inherits from a generic base class (directly or through a type alias), the TypeVar arguments must have compatible variance with the corresponding type parameters declared by the base class.

from typing import Generic, TypeVar

T = TypeVar("T")            # invariant
T_co = TypeVar("T_co", covariant=True)

class Base(Generic[T]): ...

class Bad(Base[T_co]): ...  # E — invariant param gets covariant arg

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial generics_variance 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/generics_variance