X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/712f8b37fb12a40ec6ea86903f44c2d0750f56a3..7f7673d941a947a8d392c8c0866d3d588affc174:/src/black/linegen.py 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)