Skip to content

Commit

Permalink
Fix crash with walrus + await + with
Browse files Browse the repository at this point in the history
Fixes psf#3472
  • Loading branch information
JelleZijlstra committed Dec 25, 2022
1 parent 3feff21 commit c31425e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -33,6 +33,7 @@
string lambda values are now wrapped in parentheses (#3440)
- Exclude string type annotations from improved string processing; fix crash when the
return type annotation is stringified and spans across multiple lines (#3462)
- Fix a crash in preview style with walrus operators used in `await` statements (#3473)

### Configuration

Expand Down
1 change: 1 addition & 0 deletions src/black/linegen.py
Expand Up @@ -1270,6 +1270,7 @@ def maybe_make_parens_invisible_in_atom(
syms.return_stmt,
syms.except_clause,
syms.funcdef,
syms.with_stmt,
# these ones aren't useful to end users, but they do please fuzzers
syms.for_stmt,
syms.del_stmt,
Expand Down
7 changes: 7 additions & 0 deletions tests/data/py_38/pep_572_remove_parens.py
Expand Up @@ -49,6 +49,9 @@ def a():
def this_is_so_dumb() -> (please := no):
pass

async def await_the_walrus():
with (x := await y):
pass

# output
if foo := 0:
Expand Down Expand Up @@ -103,3 +106,7 @@ def a():
def this_is_so_dumb() -> (please := no):
pass


async def await_the_walrus():
with (x := await y):
pass

0 comments on commit c31425e

Please sign in to comment.