title: Default vs optional function parameters with type hints
body: <p>So the function <code>gendata</code> accepts two optional parameters (<code>name</code> and <code>source</code>) and then based on the value of <code>source</code> invokes <code>parser</code> with the same parameters that are however required in this function.</p>
  
  <ol>
  <li>What is the recommended way to solve the required vs. none required parameters?</li>
  <li>There is an example in Python docs for <a href="https://docs.python.org/3/library/typing.html#typing.Type" rel="nofollow noreferrer">typing.Types</a> and it shows that <code>Type[SuperClass]</code> should accept all child classes that inherit from it. Why <code>mypy</code> complains in this case and why only for arg 1 and 2 but not 3 (<code>source</code>)?</li>
  </ol>
  
  <p><strong>exmaple.py:</strong></p>
  
  <pre><code>from dataclasses import dataclass
  from typing import List, Optional, Type
  
  
  @dataclass
  class BaseItem:
      name: str
      value: int
  
  
  @dataclass
  class Item(BaseItem):
      pass
  
  
  @dataclass
  class AnotherItem(BaseItem):
      pass
  
  
  def parser(item: Type[BaseItem], name: str, source: int) -&gt; Type[BaseItem]:
      item.value = source
      return item
  
  
  def gendata(
      items: List[Item], name: Optional[str] = None, source: Optional[int] = None
  ) -&gt; None:
      for item in items:
          if source:
              item = parser(item, name, source)
  </code></pre>
  
  <p><strong>Testing:</strong></p>
  
  <pre><code>$ mypy example.py 
  e.py:31: error: Incompatible types in assignment (expression has type "Type[BaseItem]", variable has type "Item")
  e.py:31: error: Argument 1 to "parser" has incompatible type "Item"; expected "Type[BaseItem]"
  e.py:31: error: Argument 2 to "parser" has incompatible type "Optional[str]"; expected "str"
  Found 3 errors in 1 file (checked 1 source file)
  </code></pre>