Title: Add additional optional type parameter to `typing.ContextManager` and `typing.AbstractContextManager` · Issue #118660 · python/cpython · GitHub
Open Graph Title: Add additional optional type parameter to `typing.ContextManager` and `typing.AbstractContextManager` · Issue #118660 · python/cpython
X Title: Add additional optional type parameter to `typing.ContextManager` and `typing.AbstractContextManager` · Issue #118660 · python/cpython
Description: Feature or enhancement Proposal: As part of python/typeshed#11048 contextlib.AbstractContextManager and contextlib.AbstractAsyncContextManager received an additional optional type parameter for the return value of __exit__ in order to ha...
Open Graph Description: Feature or enhancement Proposal: As part of python/typeshed#11048 contextlib.AbstractContextManager and contextlib.AbstractAsyncContextManager received an additional optional type parameter for the...
X Description: Feature or enhancement Proposal: As part of python/typeshed#11048 contextlib.AbstractContextManager and contextlib.AbstractAsyncContextManager received an additional optional type parameter for the...
Opengraph URL: https://github.com/python/cpython/issues/118660
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add additional optional type parameter to `typing.ContextManager` and `typing.AbstractContextManager`","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nAs part of https://github.com/python/typeshed/pull/11048 `contextlib.AbstractContextManager` and `contextlib.AbstractAsyncContextManager` received an additional optional type parameter for the return value of `__exit__` in order to have greater control over code-flow analysis in type checkers with things like `ExitStack`.\n\nThe `contextlib` `ABC`s don't require any changes, since they accept an arbitrary number of arguments at runtime, but the aliases that live in `typing` are a different story. These will reject the additional parameter at runtime, throwing an exception.\n\n@JelleZijlstra Added support for type var defaults for `typing._SpecialGenericAlias` in #118648, we could leverage that work to add the new optional parameter to the typing aliases, so they can support the same number of type parameters as their `contextlib` counterparts.\n\n### Has this already been discussed elsewhere?\n\nI have already discussed this feature proposal on Discourse\n\n### Links to previous discussion of this feature:\n\nhttps://discuss.python.org/t/add-an-else-clause-to-with-statements-to-detect-early-termination/38031\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-118681\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/Daverball","@type":"Person","name":"Daverball"},"datePublished":"2024-05-06T17:28:30Z","url":"https://github.com/python/cpython/issues/118660"}
| 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:39ee6308-5c89-a692-b032-03c82088f81d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5FC:BACA4:2E80586:3D947AF:6B0029B3 |
| html-safe-nonce | 8628dfbb9224b903bce909fcd230a6de8fd77d819aff1a2fd2b026fa17eec7a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUZDOkJBQ0E0OjJFODA1ODY6M0Q5NDdBRjo2QjAwMjlCMyIsInZpc2l0b3JfaWQiOiIzNjYxNjU3OTI0NTcwMTk2NDAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2596c75f475f2c91a19f4bdbc83e0780792ccbf1ec7099cc8a5f69efd4ed3561 |
| hovercard-subject-tag | issue:2281373858 |
| 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/cpython/118660/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30a48b59809192c900027347370e306fbae8bf19fc9f107b686e352b43cc7405/python/cpython/issues/118660 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30a48b59809192c900027347370e306fbae8bf19fc9f107b686e352b43cc7405/python/cpython/issues/118660 |
| og:image:alt | Feature or enhancement Proposal: As part of python/typeshed#11048 contextlib.AbstractContextManager and contextlib.AbstractAsyncContextManager received an additional optional type parameter for the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Daverball |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width