From f3bb84770d1a193f78aab657232bd5e6e75f3bd1 Mon Sep 17 00:00:00 2001 From: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:59:22 -0600 Subject: [PATCH] fix: Don't add unnessecary walrus parentheses Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> --- src/black/linegen.py | 7 +++++-- test.py | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 test.py diff --git a/src/black/linegen.py b/src/black/linegen.py index b77849aa97c..9a3eb0ce73f 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -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, @@ -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 diff --git a/test.py b/test.py deleted file mode 100644 index 6962789a353..00000000000 --- a/test.py +++ /dev/null @@ -1,3 +0,0 @@ -{ - "is_update": (up := commit.hash in update_hashes) -}