X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/a24e1f795975350f7b1d8898d831916a9f6dbc6a..7f7673d941a947a8d392c8c0866d3d588affc174:/src/black/nodes.py diff --git a/src/black/nodes.py b/src/black/nodes.py index f130bff..37b96a4 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -9,6 +9,7 @@ from typing import ( List, Optional, Set, + Tuple, TypeVar, Union, ) @@ -400,6 +401,10 @@ def whitespace(leaf: Leaf, *, complex_subscript: bool) -> str: # noqa: C901 elif p.type == syms.sliceop: return NO + elif p.type == syms.except_clause: + if t == token.STAR: + return NO + return SPACE @@ -559,9 +564,14 @@ def is_one_tuple(node: LN) -> bool: ) -def is_one_tuple_between(opening: Leaf, closing: Leaf, leaves: List[Leaf]) -> bool: - """Return True if content between `opening` and `closing` looks like a one-tuple.""" - if opening.type != token.LPAR and closing.type != token.RPAR: +def is_one_sequence_between( + opening: Leaf, + closing: Leaf, + leaves: List[Leaf], + brackets: Tuple[int, int] = (token.LPAR, token.RPAR), +) -> bool: + """Return True if content between `opening` and `closing` is a one-sequence.""" + if (opening.type, closing.type) != brackets: return False depth = closing.bracket_depth + 1