On Tue, Jan 12, 2021 at 1:00 PM Matthew Rahtz via Typing-sig <typing-sig@python.org> wrote:
[...] That is, is `Tuple` covariant?

Hmm, I actually can't find solid information on this in PEP 483 or 484. https://github.com/python/typing/issues/2 suggests the answer is 'yes', but I guess this is only true in the `Tuple[SomeType, ...]` form; a `Tuple[Child]` doesn't seem like it should be automatically be a subclass of `Tuple[Parent]`.

To me, PEP 483 answers this clearly (if you remember that the dots here are *not* the ellipsis token but just mean "and so on through" :-):

> `Tuple[u1, u2, ..., um]` is a subtype of `Tuple[t1, t2, ..., tn]` if they have the same length `n==m` and each `ui` is a subtype of `ti`.

I don't think we should consider any of the other suggestions you offered related to variance.

If you're at all sensitive to Eric's suggestion of only supporting variadics when used with the `*Ts` notation (or the `Expand[Ts]` equivalent) then I think we have a very solid case for using `TypeVar(bound=Tuple)`.

Another argument is that TypeScript does all the same things without explicitly needing to mark the type variables involved as being special -- they just write things like
```
type Foo<T extends unknown[]> = [string, ...T, number];
```
which to me feels like the moral equivalent to
```
T = TypeVar("T", bound=Tuple)
Foo = Tuple[str, *T, float]
```
See e.g. TypeScript: Variadic Tuple Types Preview (fettblog.eu)

--
--Guido van Rossum (python.org/~guido)