title: How to type hint a generator in Python 3?
body: <p>According to <a href="https://www.python.org/dev/peps/pep-0484/#annotating-generator-functions-and-coroutines" rel="noreferrer">PEP-484</a>, we should be able to type hinting a generator function as follows:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Generator
  
  def generate() -&gt; Generator[int, None, None]:
      for i in range(10):
          yield i
  
  for i in generate():
      print(i)
  </code></pre>
  <p>However, the list comprehension gives the following error in PyCharm.</p>
  <blockquote>
  <p>Expected 'collections.Iterable', got 'Generator[int, None, None]' instead less... (⌘F1)</p>
  </blockquote>
  <p>Any idea why PyCharm is considering this as error?</p>
  <hr />
  <p>A few clarification after reading some answers. I am using PyCharm Community Edition 2016.3.2 (the latest version) and have imported the <code>typing.Generator</code> (updated in the code). The above code runs just fine, but PyCharm considers this an error:</p>
  <p><a href="https://i.stack.imgur.com/PGSwC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PGSwC.png" alt="enter image description here" /></a></p>
  <p>So, I'm wondering if this is actually an error or an unsupported feature in PyCharm.</p>