Fix parsing of walrus operator in complex with statements (#4630)

This commit is contained in:
Tushar Sadhwani 2025-03-21 02:30:11 +05:30 committed by GitHub
parent dd278cb316
commit 6144c46c6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

View File

@ -10,6 +10,8 @@
<!-- Changes that affect Black's stable style -->
- Fix crash while formatting a long `del` statement containing tuples (#4628)
- Fix crash while formatting expressions using the walrus operator in complex
`with` statements (#4630)
### Preview style

View File

@ -1649,6 +1649,7 @@ def maybe_make_parens_invisible_in_atom(
syms.except_clause,
syms.funcdef,
syms.with_stmt,
syms.testlist_gexp,
syms.tname,
# these ones aren't useful to end users, but they do please fuzzers
syms.for_stmt,

View File

@ -14,3 +14,8 @@
f((a := b + c for c in range(10)), x)
f(y=(a := b + c for c in range(10)))
f(x, (a := b + c for c in range(10)), y=z, **q)
# Don't remove parens when assignment expr is one of the exprs in a with statement
with x, (a := b):
pass