Skip to content

Commit

Permalink
fix: Don't add unnessecary walrus parentheses
Browse files Browse the repository at this point in the history
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
  • Loading branch information
cobaltt7 committed Jan 17, 2024
1 parent a8c4c9f commit f3bb847
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/black/linegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ def visit_dictsetmaker(self, node: Node) -> Iterator[Line]:
if i == 0:
continue
if node.children[i - 1].type == token.COLON:
if child.type == syms.atom and child.children[0].type == token.LPAR:
if (
child.type == syms.atom
and child.children[0].type == token.LPAR
and not is_walrus_assignment(child)
):
if maybe_make_parens_invisible_in_atom(
child,
parent=node,
Expand Down Expand Up @@ -1545,7 +1549,6 @@ def maybe_make_parens_invisible_in_atom(
and max_delimiter_priority_in_atom(node) >= COMMA_PRIORITY
)
or is_tuple_containing_walrus(node)
or is_walrus_assignment(node)
):
return False

Expand Down
3 changes: 0 additions & 3 deletions test.py

This file was deleted.

0 comments on commit f3bb847

Please sign in to comment.