Title: Spurious error on bare `yield` in a context manager under strict-optional · Issue #1958 · python/mypy · GitHub
Open Graph Title: Spurious error on bare `yield` in a context manager under strict-optional · Issue #1958 · python/mypy
X Title: Spurious error on bare `yield` in a context manager under strict-optional · Issue #1958 · python/mypy
Description: Running mypy --strict-optional on the mypy codebase itself, we get this error: mypy/build.py: note: In member "wrap_context" of class "State": mypy/build.py:1170: error: Yield value expected The function in question looks like this: @con...
Open Graph Description: Running mypy --strict-optional on the mypy codebase itself, we get this error: mypy/build.py: note: In member "wrap_context" of class "State": mypy/build.py:1170: error: Yield value expected The fu...
X Description: Running mypy --strict-optional on the mypy codebase itself, we get this error: mypy/build.py: note: In member "wrap_context" of class "State": mypy/build.py:1170: error: Yield v...
Opengraph URL: https://github.com/python/mypy/issues/1958
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spurious error on bare `yield` in a context manager under strict-optional","articleBody":"Running `mypy --strict-optional` on the mypy codebase itself, we get this error:\n\n```\nmypy/build.py: note: In member \"wrap_context\" of class \"State\":\nmypy/build.py:1170: error: Yield value expected\n```\n\nThe function in question looks like this:\n\n```\n @contextlib.contextmanager\n def wrap_context(self) -> Iterator[None]:\n save_import_context = self.manager.errors.import_context()\n self.manager.errors.set_import_context(self.import_context)\n try:\n yield\n except CompileError:\n raise\n except Exception as err:\n report_internal_error(err, self.path, 0)\n self.manager.errors.set_import_context(save_import_context)\n self.check_blockers()\n```\n\nThis is pretty sensible idiomatic code. Arguably there might be some other appropriate annotation to write for the return type; bracketing that question, it looks to be perfectly well-typed code that shouldn't produce an error. It's also not immediately clear to me how to work around it, except I guess with a `# type: ignore`.\n\nI suspect this is related to the complicated treatment we give in some places to None as a return type -- cf #1509, #299, #359 -- and that treating None in a more regular way as discussed in #1278 and #1847 would fix it.\n\nIt may also be related to #1933, but I haven't yet read through that discussion to understand what's going on there.\n","author":{"url":"https://github.com/gnprice","@type":"Person","name":"gnprice"},"datePublished":"2016-07-29T02:00:34Z","url":"https://github.com/python/mypy/issues/1958"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bca93fca-f7f9-6e6d-c850-22107e6da8ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF3E:2573D7:1CEB687:273861D:6B000C8B |
| html-safe-nonce | c457f1479073f8203721a95a239c9e680fb17e3ef5608d1c130d556942322596 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjNFOjI1NzNENzoxQ0VCNjg3OjI3Mzg2MUQ6NkIwMDBDOEIiLCJ2aXNpdG9yX2lkIjoiNjQ1OTg0ODg4NzY0ODY1MjQyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 777d7b0cdf56d841f7ce9b4c7792bbad6b1eecd8dd33ccd418e0ab591334c032 |
| hovercard-subject-tag | issue:168235264 |
| 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/_view_fragments/issues/show/python/mypy/1958/issue_layout |
| twitter:image | https://opengraph.githubassets.com/83075bc0af7764373dc23dde1bfa7fc64f86651a228dc8d0eadcabc949ba1cae/python/mypy/issues/1958 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/83075bc0af7764373dc23dde1bfa7fc64f86651a228dc8d0eadcabc949ba1cae/python/mypy/issues/1958 |
| og:image:alt | Running mypy --strict-optional on the mypy codebase itself, we get this error: mypy/build.py: note: In member "wrap_context" of class "State": mypy/build.py:1170: error: Yield value expected The fu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gnprice |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width