Title: mypy is confused by return values from generators · Issue #695 · python/mypy · GitHub
Open Graph Title: mypy is confused by return values from generators · Issue #695 · python/mypy
X Title: mypy is confused by return values from generators · Issue #695 · python/mypy
Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
Open Graph Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
X Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.
Mail addresses
notifications@github.com
Opengraph URL: https://github.com/python/mypy
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy is confused by return values from generators","articleBody":"This is fine:\n\n```\nfrom typing import Iterator\n\ndef foo() -> Iterator[int]:\n yield 42\n\nx = next(foo()) + 1000\nprint(x)\n```\n\nBut now try this:\n\n```\nfrom typing import Iterator\n\ndef foo() -> Iterator[int]:\n yield 42\n return 'abc'\n```\n\nThis complains about the `return` statement:\n\n```\ng.py, line 5: Incompatible return value type: expected typing.Iterator[builtins.int], got builtins.str\n```\n\nIt's matching the generator return value (which is only accessible by a caller that uses `yield from`) to the declared return type (which is just the type of what you get by calling `foo()`.\n","author":{"url":"https://github.com/gvanrossum","@type":"Person","name":"gvanrossum"},"datePublished":"2015-05-20T22:11:46Z","url":"https://github.com/python/mypy/issues/695"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:cee704b6-9dc1-cc25-2701-826f52bddc8c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC9C:C25F6:730A5A:9ED175:6B009DC5 |
| html-safe-nonce | cb29bd80b938c81e6482e6d3b5ce2069b3891079338f48e294abe639b768bf69 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzlDOkMyNUY2OjczMEE1QTo5RUQxNzU6NkIwMDlEQzUiLCJ2aXNpdG9yX2lkIjoiMzE1ODU4MDEyNDQ5Mjc5OTQyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 57207fd8ab8dcf22d09d36037712fd5d3f6ecec1bf013def6e28942b55ba04c2 |
| hovercard-subject-tag | repository:7053637 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/mypy/issues/695 |
| twitter:image | https://opengraph.githubassets.com/ae79ad9131483d454da0af1b001fa219a4dacdfbb7a97b75f32e108879dc5ccc/python/mypy |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae79ad9131483d454da0af1b001fa219a4dacdfbb7a97b75f32e108879dc5ccc/python/mypy |
| og:image:alt | Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 52c95ce7e48016ae14399656b4ee812462b6f1fa28c5008c8394da64794c00b8 |
| turbo-cache-control | no-cache |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1c9ddec8215f9a94e295c8310c3579b9c54ba31a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width