title: Asking isinstance on a Union[...] type
body: <p>I'm trying to ask an <code>isinstance</code> question on a user defined type: <code>ConstData = Union[int, str]</code>:</p>
  <pre><code>from typing import Union, Optional
  ConstData = Union[int, str]
  def foo(x) -&gt; Optional[ConstData]:
      if isinstance(x, ConstData):  # &lt;--- this doesn't work
      # if isinstance(x, (int, str)): &lt;--- this DOES work ...
          return x
      return None
  </code></pre>
  <p>Sadly enough, it doesn't work:</p>
  <pre><code>$ mypy main.py
  main.py:4: error: Parameterized generics cannot be used with class or instance checks
  main.py:4: error: Argument 2 to &quot;isinstance&quot; has incompatible type &quot;object&quot;; expected &quot;Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]&quot;
  Found 2 errors in 1 file (checked 1 source file)
  </code></pre>
  <p>Is there any elegant way to solve this?</p>