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

Don't strip parens in assert / return with assign expr #2143

Merged

Commits on Apr 26, 2021

  1. 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).
    ichard26 committed Apr 26, 2021
    Copy the full SHA
    0cf1193 View commit details
    Browse the repository at this point in the history