GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Walrus in comprehension can leak into PEP 695 scope · Issue #104640 · python/cpython

Walrus in comprehension can leak into PEP 695 scope #104640

New issue
Copy link
New issue
Copy link
Closed
#104641
Closed
Walrus in comprehension can leak into PEP 695 scope#104640
#104641
Copy link
Assignees
JelleZijlstra
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@JelleZijlstra
JelleZijlstra
opened on May 19, 2023
Issue body actions

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 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.

Linked PRs

  • gh-104640: Disallow walrus in comprehension within type scopes #104641

Activity

  1. JelleZijlstra
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 19, 2023
  2. JelleZijlstra
    self-assigned this
    on May 19, 2023
  3. JelleZijlstra
    added a commit that references this issue on May 19, 2023

    pythongh-104640: Disallow walrus in comprehension within type scopes

    d43cf9c
  4. JelleZijlstra
    closed this as completedin #104641on May 19, 2023
  5. JelleZijlstra
    added a commit that references this issue on May 19, 2023

    gh-104640: Disallow walrus in comprehension within type scopes (#104641)

    8a8853a
  6. carljm
    added a commit that references this issue on May 20, 2023

    Merge branch 'main' into gsallam/main

    ea5965a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.