Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.13] gh-115528: Update language reference for PEP 646 (GH-121181) #124632

Merged
merged 1 commit into from
Sep 26, 2024

Commits on Sep 26, 2024

  1. pythongh-115528: Update language reference for PEP 646 (pythonGH-121181)

    To recap: the objective is to make starred expressions valid in `subscription`,
    which is used for generics: `Generic[...]`, `list[...]`, etc.
    
    What _is_ gramatically valid in such contexts? Seemingly any of the following.
    (At least, none of the following throw `SyntaxError` in a 3.12.3 REPL.)
    
        Generic[x]
        Generic[*x]
        Generic[*x, y]
        Generic[y, *x]
        Generic[x := 1]
        Generic[x := 1, y := 2]
    
    So introducting
    
        flexible_expression: expression | assignment_expression | starred_item
    
    end then switching `subscription` to use `flexible_expression` sorts that.
    
    But then we need to field `yield` - for which any of the following are
    apparently valid:
    
        yield x
        yield x,
        yield x, y
        yield *x,
        yield *x, *y
    
    Introducing a separate `yield_list` is the simplest way I've been figure out to
    do this - separating out the special case of `starred_item ,`.
    
    (cherry picked from commit 7d3497f)
    
    Co-authored-by: Matthew Rahtz <[email protected]>
    Co-authored-by: Jelle Zijlstra <[email protected]>
    2 people authored and miss-islington committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    e518172 View commit details
    Browse the repository at this point in the history