title: How do I add default parameters to functions when using type hinting?
body: <p>If I have a function like this:</p>
  
  <pre><code>def foo(name, opts={}):
    pass
  </code></pre>
  
  <p>And I want to add type hints to the parameters, how do I do it? The way I assumed gives me a syntax error:</p>
  
  <pre><code>def foo(name: str, opts={}: dict) -&gt; str:
    pass
  </code></pre>
  
  <p>The following doesn't throw a syntax error but it doesn't seem like the intuitive way to handle this case:</p>
  
  <pre><code>def foo(name: str, opts: dict={}) -&gt; str:
    pass
  </code></pre>
  
  <p>I can't find anything in the <a href="https://docs.python.org/3/library/typing.html" rel="noreferrer"><code>typing</code> documentation</a> or on a Google search. </p>
  
  <p>Edit: I didn't know how default arguments worked in Python, but for the sake of this question, I will keep the examples above. In general it's much better to do the following:</p>
  
  <pre><code>def foo(name: str, opts: dict=None) -&gt; str:
    if not opts:
      opts={}
    pass
  </code></pre>