title: typing: type hinting when function returns tuple with unpacked list
body: <p>I have this:</p>
  <pre><code>from typing import Tuple
  import random
  
  a = random.randint(100) # some random number
  
  def foo(a: int) -&gt; Tuple:
      b = []
      for _ in random.randint(0, 10):
         b.append(random.randint(-5, 5) # adding random numbers to b
      return a, *b
  </code></pre>
  <p>And I want to write <strong>return type</strong> for this function, but I don't now how to do this <em>properly</em>:</p>
  <p>I tried this:</p>
  <pre><code>from typing import Tuple
  import random
  
  a = random.randint(100) # some random number. It doesn't matter
  
  def foo(a: int) -&gt; Tuple[int, *Tuple[int, ...]]:
      b = []
      for _ in random.randint(0, 10):
         b.append(random.randint(-5, 5) # adding random numbers to b
      return a, *b
  </code></pre>
  <p><strong>Pycharm</strong> with <strong>mypy</strong> says: <code>foo(a: int) -&gt; Tuple[int, Any]</code>
  But I need the function to return the type of variable that was passed to it</p>
  <p>In a <em>real project</em>, it takes a <strong>generic</strong> and returns a <strong>tuple</strong> with the object and the <strong>unpacked list</strong> in it for readability</p>
  <p>Real function:</p>
  <pre><code>...
      def get_entities_with(self, *component_types):
          for entity in self.entities.values():
              require_components = [component for component in entity.components if type(component) in component_types]
              if len(require_components) == len(component_types):
                  yield entity, *require_components
  ...
  </code></pre>
  <p>.pyi File:</p>
  <pre><code>T = TypeVar(&quot;T&quot;)
  ...
      def get_entities_with(self, *components:Type[T]) -&gt; Generator[Entity, *Tuple[T, ...]]: ...
  </code></pre>