With mypy, I can check the variance of the type parameter T in a generic class as shown below:
class A: ...
class B(A): ...
class C(B): ...
class Cls[T]:
def meth(self, x: T) -> None: ...
cls1: Cls[A] = Cls[B]() # Error
cls2: Cls[B] = Cls[B]() # No error
cls3: Cls[C] = Cls[B]() # No error
# So `T` is `Contravariant`.
Now, is there any way to check the variance of the type parameter T in a generic function?
class A: ...
class B(A): ...
class C(B): ...
# ↓ What variance is it?
def func[T](x: T) -> None: ...