You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to define a type variable as covariant. For example, the type variable of Iterable[t] could be covariant, and then Iterable[x] would a subtype of Iterable[y] if x is a subtype of y. Currently this is not the case, which is sometimes awkward, and this would even more awkward with union types.
Not sure about the syntax. Maybe something like this:
T = typevar('T', covariant=True)
(Ouch, looks pretty technical.)
Covariant type variables must not appear within method argument types or instance variable types, i.e. they are only valid as return types. Also, only read-only properties can have types with covariant type variables.
The text was updated successfully, but these errors were encountered:
It should be possible to define a type variable as covariant. For example, the type variable of Iterable[t] could be covariant, and then Iterable[x] would a subtype of Iterable[y] if x is a subtype of y. Currently this is not the case, which is sometimes awkward, and this would even more awkward with union types.
Not sure about the syntax. Maybe something like this:
(Ouch, looks pretty technical.)
Covariant type variables must not appear within method argument types or instance variable types, i.e. they are only valid as return types. Also, only read-only properties can have types with covariant type variables.
The text was updated successfully, but these errors were encountered: