title: Can the * (unpacking) operator be typed in Python? Or any other variadic args function such that all variadic types are in the result type?
body: <p>Working with type stubs, I'm wondering if it's possible to express a type in Python that allows you to type this correctly for any number of arguments:</p>
  <pre class="lang-py prettyprint-override"><code>def test(*args):
    return args
  </code></pre>
  <p>At first glance, I came with:</p>
  <pre class="lang-py prettyprint-override"><code>T = TypeVar('T')
  def test(*args: T) -&gt; Tuple[T, ...]:
    return args
  </code></pre>
  <p>But this of course will only type correctly the first T.</p>
  <p>Is the only possible way to write the overrides for all arities?</p>
  <pre class="lang-py prettyprint-override"><code>T1 = TypeVar('T1')
  T2 = TypeVar('T2')
  T3 = TypeVar('T3')
  T4 = TypeVar('T4')
  
  @overload
  def test(arg1: T1) -&gt; Tuple[T1]: ...
  @overload
  def test(arg1: T1, arg2: T2) -&gt; Tuple[T1, T2]: ...
  @overload
  def test(arg1: T1, arg2: T2, arg3: T3) -&gt; Tuple[T1, T2, T3]: ...
  @overload
  def test(arg1: T1, arg2: T2, arg3: T3, arg4: T4) -&gt; Tuple[T1, T2, T3, T4]: ...
  # etc
  def test(*args: Any) -&gt; Tuple[Any, ...]:
    return args
  </code></pre>
  <p>This is not complete either, since it does not carry enough type information to type something like:</p>
  <pre class="lang-py prettyprint-override"><code>x: Tuple[int, int, str] = test(*[1, 2, &quot;4&quot;])
  </code></pre>