Skip to content

Preview style incorrectly removes parens from walrus in annotation #3419

@JelleZijlstra

Description

@JelleZijlstra
$ black -c 'def this_is_so_dumb() -> (please := no): ...'
def this_is_so_dumb() -> (please := no):
    ...
$ black --preview -c 'def this_is_so_dumb() -> (please := no): ...'
def this_is_so_dumb() -> (please := no): ...
error: cannot format <string>: Cannot parse: 1:32: def this_is_so_dumb() -> please := no:
$ black --version
black, 22.12.0 (compiled: yes)
Python (CPython) 3.9.14

Found this in CI for #3418, cf. #3407.

Seems like a result of #2990, cc @jpy-git.

Broader learning: for all stable style tests, we should run tests in preview style that assert that formatting at least succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions