In accordance with PEP-484, we can introduce allusions to the function of the generator as follows:
from typing import Generator def generate() -> Generator[int, None, None]: for i in range(10): yield i for i in generate(): print(i)
However, understanding the list gives the following error in PyCharm.
Expected 'collections.Iterable', got 'Generator[int, None, None]' instead less... (⌘F1)
Any idea why PyCharm treats this as an error? Thanks.
A few clarifications after reading some answers. I am using PyCharm Community Edition 2016.3.2 (latest version) and imported typing.Generator (updated in code). The above code works very well, but PyCharm considers this an error:

So, I am wondering if this is really a bug or an unsupported function in PyCharm.
Jinho choi
source share