Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't strip parens in assert / return with assign expr
Black would previously strip the parenthesis away from statements like this these ones: assert (spam := 12 + 1) return (cheese := 1 - 12) Which happens to be invalid code. Now before making the parenthesis invisible, Black checks if the assignment expression's parent is an assert stamtment, aborting if True. Raise, yield, and await are already handled fine. I added a bunch of test cases from the PEP defining asssignment expressions (PEP 572).
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters