-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overridestopic-type-variables
Description
In generic inheritance, we can't change the variance of a type from invariant to covariant/contravariant. This should probably be rejected:
IV = TypeVar('IV')
CV = TypeVar('CV', covariant=True)
class A(Generic[IV]): ... # Bunch of methods
class B(A[CV], Generic[CV]): pass # Error, type variable should be invariant
Going from covariant to invariant is fine (for example, List has to do this since it subclasses Sequence, which is covariant).
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overridestopic-type-variables