title: Mypy: How to specify return and input type for builder function?
body: <p>I want to make some sort of builder function in Python with type annotation.</p>
  <pre class="lang-py prettyprint-override"><code>def build_object(target_class: TargetType) -&gt; ReturnType:
      return target_class()
  </code></pre>
  <p>How to correctly specify <code>TargetType</code> and <code>ReturnType</code>?
  So far I have one option but I have no idea if this is correct:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Type, TypeVar
  
  TargetObjType = TypeVar(&quot;TargetObjType&quot;)
  
  def build_object(target_class: Type[TargetObjType]) -&gt; TargetObjType:
      return target_class()
  </code></pre>
  <p>I have an error from <code>mypy</code> if I pass arguments into class constructor:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Type, TypeVar
  
  TargetObjType = TypeVar(&quot;TargetObjType&quot;)
  
  def build_object(target_class: Type[TargetObjType]) -&gt; TargetObjType:
      return target_class(1)  # mypy error
  </code></pre>
  <p>Is there a way to fix this without <code># type: ignore</code>?</p>