Is there the function (or the way) to check which variance is used for a generic class?

Is there the function (or the way) to check which variance is used for a generic class like below?

*Memo:

  • There are covariance, contravariance and invariance.
class MyCls[T]:

    def __init__(self, x: T) -> None:
        self._x: T = x

# ↓ ↓ Here ↓ ↓
variance(MyCls) # covariance

I don’t really think so, but I think a tool like this that also tells you exactly WHY the class has a specific variance could be very useful and I would have needed it multiple times before.

If you use pyright/pylance or derived in your IDE you can get the info when hovering over the type var and request information. E.g. through cmd + K on a Mac + vscode. It will say covariant/invariant/contravariant.