{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/5020","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/5020/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/5020/comments","events_url":"https://api.github.com/repos/python/mypy/issues/5020/events","html_url":"https://github.com/python/mypy/issues/5020","id":322448291,"number":5020,"title":"Generator expression returned from a function is interpreted as an Iterator","user":{"login":"gmolau","id":23221000,"avatar_url":"https://avatars3.githubusercontent.com/u/23221000?v=4","gravatar_id":"","url":"https://api.github.com/users/gmolau","html_url":"https://github.com/gmolau","followers_url":"https://api.github.com/users/gmolau/followers","following_url":"https://api.github.com/users/gmolau/following{/other_user}","gists_url":"https://api.github.com/users/gmolau/gists{/gist_id}","starred_url":"https://api.github.com/users/gmolau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmolau/subscriptions","organizations_url":"https://api.github.com/users/gmolau/orgs","repos_url":"https://api.github.com/users/gmolau/repos","events_url":"https://api.github.com/users/gmolau/events{/privacy}","received_events_url":"https://api.github.com/users/gmolau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"JelleZijlstra","id":906600,"avatar_url":"https://avatars0.githubusercontent.com/u/906600?v=4","gravatar_id":"","url":"https://api.github.com/users/JelleZijlstra","html_url":"https://github.com/JelleZijlstra","followers_url":"https://api.github.com/users/JelleZijlstra/followers","following_url":"https://api.github.com/users/JelleZijlstra/following{/other_user}","gists_url":"https://api.github.com/users/JelleZijlstra/gists{/gist_id}","starred_url":"https://api.github.com/users/JelleZijlstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JelleZijlstra/subscriptions","organizations_url":"https://api.github.com/users/JelleZijlstra/orgs","repos_url":"https://api.github.com/users/JelleZijlstra/repos","events_url":"https://api.github.com/users/JelleZijlstra/events{/privacy}","received_events_url":"https://api.github.com/users/JelleZijlstra/received_events","type":"User","site_admin":false},"assignees":[{"login":"JelleZijlstra","id":906600,"avatar_url":"https://avatars0.githubusercontent.com/u/906600?v=4","gravatar_id":"","url":"https://api.github.com/users/JelleZijlstra","html_url":"https://github.com/JelleZijlstra","followers_url":"https://api.github.com/users/JelleZijlstra/followers","following_url":"https://api.github.com/users/JelleZijlstra/following{/other_user}","gists_url":"https://api.github.com/users/JelleZijlstra/gists{/gist_id}","starred_url":"https://api.github.com/users/JelleZijlstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JelleZijlstra/subscriptions","organizations_url":"https://api.github.com/users/JelleZijlstra/orgs","repos_url":"https://api.github.com/users/JelleZijlstra/repos","events_url":"https://api.github.com/users/JelleZijlstra/events{/privacy}","received_events_url":"https://api.github.com/users/JelleZijlstra/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-05-11T22:07:15Z","updated_at":"2018-05-11T22:42:09Z","closed_at":null,"author_association":"NONE","body":"I have a function like this:\r\n\r\n```python\r\ndef foo(some_list: List[Any]) -> Generator[Any, None, None]:\r\n    return (element for element in some_list)\r\n```\r\n\r\nThis should be correct according to the documentation of [`typing.Generator`](https://docs.python.org/3/library/typing.html#typing.Generator), yet mypy complains that it got an Iterator as the return value:\r\n\r\n    error: Incompatible return value type (got \"Iterator[Any]\", expected \"Generator[Any, None, None]\")\r\n\r\nQuestion was originally posted on Stackoverflow [here](https://stackoverflow.com/questions/50273130/mypy-error-when-returning-a-generator-expression?noredirect=1#comment87617942_50273130). Versions are Python 3.6.4, mypy 0.600."},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/388503081","html_url":"https://github.com/python/mypy/issues/5020#issuecomment-388503081","issue_url":"https://api.github.com/repos/python/mypy/issues/5020","id":388503081,"user":{"login":"JelleZijlstra","id":906600,"avatar_url":"https://avatars0.githubusercontent.com/u/906600?v=4","gravatar_id":"","url":"https://api.github.com/users/JelleZijlstra","html_url":"https://github.com/JelleZijlstra","followers_url":"https://api.github.com/users/JelleZijlstra/followers","following_url":"https://api.github.com/users/JelleZijlstra/following{/other_user}","gists_url":"https://api.github.com/users/JelleZijlstra/gists{/gist_id}","starred_url":"https://api.github.com/users/JelleZijlstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JelleZijlstra/subscriptions","organizations_url":"https://api.github.com/users/JelleZijlstra/orgs","repos_url":"https://api.github.com/users/JelleZijlstra/repos","events_url":"https://api.github.com/users/JelleZijlstra/events{/privacy}","received_events_url":"https://api.github.com/users/JelleZijlstra/received_events","type":"User","site_admin":false},"created_at":"2018-05-11T22:42:09Z","updated_at":"2018-05-11T22:42:09Z","author_association":"COLLABORATOR","body":"Thanks for the report! This should be pretty easy to fix: the bad code is at https://github.com/python/mypy/blob/master/mypy/checkexpr.py#L2231. Would you be interested in sending a PR to fix it?"}}
{"actor":{"display_login":"JelleZijlstra"}}