title: Should mypy infer type from Union options?
body: <p>In the following code <code>fn_int</code> will only be called with an <code>int</code> as an argument, yet <code>mypy</code> complains I might be passing it a <code>str</code> (viceversa for <code>fn_str</code>).</p>
  <p>Is there something I'm missing here?
  Should/can I somehow narrow down the type before passing arguments to <code>fn_int</code> and <code>fn_str</code>?</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Union
  
  
  def fn_int(arg: int) -&gt; None:
      print(arg)
  
  
  def fn_str(arg: str) -&gt; None:
      print(arg)
  
  
  def fn(arg: Union[str, int]) -&gt; None:
  
      if arg in range(4):
          fn_int(arg)
      elif arg == &quot;str&quot;:
          fn_str(arg)
      else:
          raise ValueError
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>&gt; mypy mypy_test.py
  mypy_test.py:15: error: Argument 1 to &quot;fn_int&quot; has incompatible type &quot;Union[str, int]&quot;; expected &quot;int&quot;  [arg-type]
  mypy_test.py:17: error: Argument 1 to &quot;fn_str&quot; has incompatible type &quot;Union[str, int]&quot;; expected &quot;str&quot;  [arg-type]
  </code></pre>