title: How do I declare the type of a python generator
body: <p>What is the correct way of specifying the type of a generator in python?</p>
  <p>Say for example I have the generator:</p>
  <pre><code>def f():
      yield &quot;Banana&quot;
      yield 68
  </code></pre>
  <p>How do I specify that it has the type <code>Union[str,int]</code>? Is it just <code>def f() -&gt; Union[str,int]:</code>?</p>