X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/75f99bded33abe962ca08bf16c77635ac9ca00a1..7f7673d941a947a8d392c8c0866d3d588affc174:/src/black/linegen.py?ds=sidebyside diff --git a/src/black/linegen.py b/src/black/linegen.py index caffbab..91fdeef 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -915,6 +915,15 @@ def normalize_invisible_parens( node.insert_child(index, Leaf(token.LPAR, "")) node.append_child(Leaf(token.RPAR, "")) break + elif ( + index == 1 + and child.type == token.STAR + and node.type == syms.except_clause + ): + # In except* (PEP 654), the star is actually part of + # of the keyword. So we need to skip the insertion of + # invisible parentheses to work more precisely. + continue elif not (isinstance(child, Leaf) and is_multiline_string(child)): wrap_in_parentheses(node, child, visible=False)