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 — bpo-42316: Allow unparenthesized walrus operator in indexes by lysnikolaou · Pull Request #23317 · python/cpython

Conversation

@lysnikolaou

@lysnikolaou lysnikolaou commented Nov 16, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue42316

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lysnikolaou
bpo-42316: Allow unparenthesized walrus operator in indexes
bccfa70
@lysnikolaou
lysnikolaou requested a review from pablogsal as a code owner November 16, 2020 17:28
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Nov 16, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Nov 16, 2020
@lysnikolaou
lysnikolaou requested review from gvanrossum and terryjreedy November 16, 2020 17:28
@blurb-it
📜🤖 Added by blurb_it.
3b898fe
pablogsal
pablogsal reviewed Nov 16, 2020
View reviewed changes
Comment thread Misc/NEWS.d/next/Core and Builtins/2020-11-16-17-30-03.bpo-42316._DdmpQ.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal approved these changes Nov 16, 2020
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Nov 16, 2020
pablogsal
pablogsal reviewed Nov 16, 2020
View reviewed changes
Comment thread Lib/test/test_named_expressions.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@lysnikolaou
Add more complex test with tuple index
bf7e6d4
pablogsal
pablogsal approved these changes Nov 16, 2020
View reviewed changes
@lysnikolaou
lysnikolaou merged commit cae6018 into python:master Nov 16, 2020
@lysnikolaou
lysnikolaou deleted the named-expression-index branch November 16, 2020 23:09
@bedevere-bot bedevere-bot removed the awaiting merge label Nov 16, 2020
@lysnikolaou lysnikolaou mentioned this pull request Nov 16, 2020
gh-86482: Document assignment expression need for ()s #23291
Merged
@gousaiyang gousaiyang mentioned this pull request Nov 27, 2020
Allow unparenthesized walrus in set literals, set comprehensions and indexes davidhalter/parso#162
Merged
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
@lysnikolaou @adorilson
bpo-42316: Allow unparenthesized walrus operator in indexes (pythonGH…
00e4094
…-23317)
@Brando753 Brando753 mannequin mentioned this pull request Oct 6, 2022
Walrus Operator in list index #86482
Closed
zsol added a commit to Instagram/LibCST that referenced this pull request May 27, 2023
@zsol
Allow walrus in slices
110109a
See python/cpython#23317

Raised in #930.
@zsol zsol mentioned this pull request May 27, 2023
Allow walrus in slices Instagram/LibCST#931
Closed
zsol added a commit to Instagram/LibCST that referenced this pull request Jun 7, 2023
@zsol
Fix whitespace, fstring, walrus related parse errors (#939, #938, #937,
2acc293
#936, #935, #934, #933, #932, #931)

* Allow walrus in slices

See python/cpython#23317

Raised in #930.

* Fix parsing of nested f-string specifiers

For an expression like `f"{one:{two:}{three}}"`, `three` is not in an f-string spec, and should be tokenized accordingly.

This PR fixes the `format_spec_count` bookkeeping in the tokenizer, so it properly decrements it when a closing `}` is encountered but only if the `}` closes a format_spec.

Reported in #930.

* Fix tokenizing `0else`

This is an obscure one.

`_ if 0else _` failed to parse with some very weird errors. It turns out that the tokenizer tries to parse `0else` as a single number, but when it encounters `l` it realizes it can't be a single number and it backtracks.

Unfortunately the backtracking logic was broken, and it failed to correctly backtrack one of the offsets used for whitespace parsing (the byte offset since the start of the line). This caused whitespace nodes to refer to incorrect parts of the input text, eventually resulting in the above behavior.

This PR fixes the bookkeeping when the tokenizer backtracks.

Reported in #930.

* Allow no whitespace between lambda keyword and params in certain cases

Python accepts code where `lambda` follows a `*`, so this PR relaxes validation rules for Lambdas.

Raised in #930.

* Allow any expression in comprehensions' evaluated expression


This PR relaxes the accepted types for the `elt` field in `ListComp`, `SetComp`, and `GenExp`, as well as the `key` and `value` fields in `DictComp`.

Fixes #500.

* Allow no space around an ifexp in certain cases

For example in `_ if _ else""if _ else _`.

Raised in #930. Also fixes #854.

* Allow no spaces after `as` in a contextmanager in certain cases

Like in `with foo()as():pass`

Raised in #930.

* Allow no spaces around walrus in certain cases

Like in `[_:=''for _ in _]`

Raised in #930.

* Allow no whitespace after lambda body in certain cases

Like in `[lambda:()for _ in _]`

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

Reviewers

@pablogsal pablogsal pablogsal approved these changes
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@terryjreedy terryjreedy Awaiting requested review from terryjreedy

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@lysnikolaou @pablogsal @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.