> I just realised that a related question is how unparameterized aliases should behave.
> Float32Array = Array[np.float32, *Shape]
A variadic class without parameters will bind any `Ts` to `Tuple[Any, ...]`.
So, in the above example, `x: Float32Array` will resolve to `Array[np.float32, *Tuple[Any, ...]]`.
The same goes for `class Array(Generic[T, *Ts]):` where the user says `x: Tensor`. We will resolve to `x: Tensor[Any, *Tuple[Any, ...]]`.
> IntTuple = Tuple[int, *Ts]
Like above, this will be `Tuple[int, *Tuple[Any, ...]]`.
This cleanly preserves the existing semantics and allows us to support gradual typing, without having to introduce new concepts like `Tuple[int, Any, ...]`. Given that `Tuple[int, *Tuple[Any, ...]]` expresses what we want, I don't think that we need to add syntax for `Tuple[int, Any, ...]`.
Note that this is analogous to TypeScript's syntax:
declare function accepts_T_followed_by_any<T>(x: [T, ...any]): T;
const x10: number = accepts_T_followed_by_any([1, "hello", 3]);
> I pushed a PR that fixes these, and Guido already approved and merged the change.
Ah, thanks for noticing those, Eric. We had fixed some of these issues in our running Google Doc (https://docs.google.com/document/d/1oXWyAtnv0-pbyJud8H5wkpIk8aajbkX-leJ8JXsE318/edit?usp=sharing
) but not yet updated the PR. Will try to keep the PR more up-to-date.
> The PEP specifies that `Shape` should be interpreted as `Shape[Any, ...]` when the type arguments are omitted, but there's no way to actually write this as a way to indicate "I know what I'm doing, I didn't simply forget to add the type arguments!". The proposal is effectively saying "the type system supports open-ended variadic generics, but the only way to specify them is to use a syntax that we want to discourage and will be considered an error in some type checkers. That strikes me as problematic.
> 2. We support the [T, ...] notation for generic types and type aliases that use variadic type vars.
I've been ok with first-class support of unbounded tuples as valid Ts bindings. In any case, we need to implement it internally for supporting gradual typing.
The only question had been whether we would surface this syntax to users. The main reason for not allowing users to write `Tensor[int, *Tuple[Any, ...]]` was that it might be confusing. If that is not a big concern, we can support this syntax explicitly. (Note that this is what TypeScript does.)
I favor `Tensor[int, *Tuple[Any, ...]]` over new syntax like `Tensor[int, ...]` because the former allows for more nuanced types like `Tensor[int, str, *Tuple[Any, ...], T]` whereas the latter doesn't. It's also a clear analogy that we are replacing `Ts` with `Tuple[Any, ...]`.