Title: Walrus in comprehension can leak into PEP 695 scope · Issue #104640 · python/cpython · GitHub
Open Graph Title: Walrus in comprehension can leak into PEP 695 scope · Issue #104640 · python/cpython
X Title: Walrus in comprehension can leak into PEP 695 scope · Issue #104640 · python/cpython
Description: Example: >>> class B: pass ... >>> class X[T]([(x := 3) for _ in range(2)] and B): print(x) ... 3 This is because a walrus in a comprehension assigns to the immediately enclosing scope, which is now the type parameter scope. I don't thin...
Open Graph Description: Example: >>> class B: pass ... >>> class X[T]([(x := 3) for _ in range(2)] and B): print(x) ... 3 This is because a walrus in a comprehension assigns to the immediately enclosing scope, which is no...
X Description: Example: >>> class B: pass ... >>> class X[T]([(x := 3) for _ in range(2)] and B): print(x) ... 3 This is because a walrus in a comprehension assigns to the immediately enclosing ...
Opengraph URL: https://github.com/python/cpython/issues/104640
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Walrus in comprehension can leak into PEP 695 scope","articleBody":"Example:\r\n\r\n```pycon\r\n\u003e\u003e\u003e class B: pass\r\n... \r\n\u003e\u003e\u003e class X[T]([(x := 3) for _ in range(2)] and B): print(x)\r\n... \r\n3\r\n```\r\n\r\nThis is because a walrus in a comprehension assigns to the immediately enclosing scope, which is now the type parameter scope. I don't think this causes any concrete problem right now, but I don't like it because I'd like to preserve the invariant that type parameters are the only names that can be defined in PEP 695 scopes.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104641\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2023-05-19T02:50:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/104640/cpython/issues/104640"}
| 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:af9a4c78-ce1a-7cb7-9bd2-563b39558c83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D152:21F2BE:417B6C:5D3BFF:696A0B10 |
| html-safe-nonce | 70e812b5cf87509e3521356a5546f5151b41488e75990e88c1270b58ed48d7d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTUyOjIxRjJCRTo0MTdCNkM6NUQzQkZGOjY5NkEwQjEwIiwidmlzaXRvcl9pZCI6Ijc5OTY4MTcxMDY2MjQ4NjgwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 69b557f2cfd38c68518f426245ae746c67ccef3846c033cd34779deac7931745 |
| hovercard-subject-tag | issue:1716527722 |
| 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/104640/issue_layout |
| twitter:image | https://opengraph.githubassets.com/67d61b3f554145d70a64ddcb96f44aea05a0d72535fdafed78fd4d174302c3e1/python/cpython/issues/104640 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/67d61b3f554145d70a64ddcb96f44aea05a0d72535fdafed78fd4d174302c3e1/python/cpython/issues/104640 |
| og:image:alt | Example: >>> class B: pass ... >>> class X[T]([(x := 3) for _ in range(2)] and B): print(x) ... 3 This is because a walrus in a comprehension assigns to the immediately enclosing scope, which is no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| 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 | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width