After some additional thinking — and in consideration of your responses, I have a few more thoughts to share.
I thought of a way that we could avoid all changes to the grammar and eliminate the need for `Unpack`. Assuming we remove support for packed usages of variadic type vars as I previously suggested, that would leave only unpacked usages. And if all usages are unpacked, there's no reason to require the expression `*T` or `Unpack[T]` as long as "T" is designated a variadic type var when it is defined. We could augment the existing TypeVar constructor to support a parameter called `variadic`. The only downside I see is that the use of the star makes it clear to the reader of the code that the type var is variadic, but I think we could accomplish this through a naming convention like `Ts` or `T_va`.
Here's how that would look:
```python T_va = TypeVar("T_va", variadic=True)
class Array(Generic[T_va]): def __init__(self, *args: T_va) -> None: pass
def linearize(self, value: Array[T_va]) -> Sequence[Union[T_va]]: pass ```
I like the simplicity of this. It's easy to read, easy to implement, provides backward compatibility with earlier parsers, and avoids the need to introduce an alternative form like `Unpack`.
Guido clarified that all classes that support variadic type parameters should support zero-length forms. That sounds reasonable to me.
Guido also said that unspecified-length (open-ended) variadics should be supported. I'm less convinced here. This creates complications for the type constraint solver. It also creates a bunch of tricky ambiguities for concatenation. I'll continue to play around with this in the implementation and let you know what I learn.
I like the idea of breaking this PEP into the three pieces as suggested. I could see us including some limited forms of concatenation in phase 1. In particular, we could support type argument lists that contain at most one variadic type var where the variadic type var is the last element. For example, `Tuple[int, T_va]` would be allowed but `Tuple[T_va, int]` and `Tuple[S_va, T_va]` would be errors. This would allow for removal of prefixes and basic concatenation use cases, and I think it would be relatively straightforward to implement. Support for suffixes is much tougher. And I'm not yet convinced that support for multiple variadic type vars is even theoretically possible in the general case.
-- Eric Traut Contributor to pyright and pylance Microsoft Corp.