Loading black.py +4 −4 Changes for black.py: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2728,7 +2728,7 @@ def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None: for index, child in enumerate(list(node.children)): if check_lpar: if child.type == syms.atom: if maybe_make_parens_invisible_in_atom(child): if maybe_make_parens_invisible_in_atom(child, parent=node): lpar = Leaf(token.LPAR, "") rpar = Leaf(token.RPAR, "") index = child.remove() or 0 Loading Loading @@ -2839,7 +2839,7 @@ def generate_ignored_nodes(leaf: Leaf) -> Iterator[LN]: container = container.next_sibling def maybe_make_parens_invisible_in_atom(node: LN) -> bool: def maybe_make_parens_invisible_in_atom(node: LN, parent: LN) -> bool: """If it's safe, make the parens in the atom `node` invisible, recursively. Returns whether the node should itself be wrapped in invisible parentheses. Loading @@ -2849,7 +2849,7 @@ def maybe_make_parens_invisible_in_atom(node: LN) -> bool: node.type != syms.atom or is_empty_tuple(node) or is_one_tuple(node) or is_yield(node) or (is_yield(node) and parent.type != syms.expr_stmt) or max_delimiter_priority_in_atom(node) >= COMMA_PRIORITY ): return False Loading @@ -2861,7 +2861,7 @@ def maybe_make_parens_invisible_in_atom(node: LN) -> bool: first.value = "" # type: ignore last.value = "" # type: ignore if len(node.children) > 1: maybe_make_parens_invisible_in_atom(node.children[1]) maybe_make_parens_invisible_in_atom(node.children[1], parent=parent) return False return True Loading tests/data/expression.diff +8 −3 Changes for tests/data/expression.diff: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ slice[0:1:2] slice[:] slice[:-1] @@ -133,111 +156,169 @@ @@ -133,113 +156,171 @@ numpy[-(c + 1) :, d] numpy[:, l[-2]] numpy[:, ::-1] Loading Loading @@ -214,9 +214,14 @@ + def gen(): yield from outside_of_generator a = (yield) - a = (yield) - b = ((yield)) - c = (((yield))) + a = yield + b = yield + c = yield + async def f(): await some.complicated[0].call(with_args=(True or (1 is not 1))) -print(* [] or [1]) Loading tests/data/expression.py +5 −1 Changes for tests/data/expression.py: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -169,6 +169,8 @@ def gen(): yield from outside_of_generator a = (yield) b = ((yield)) c = (((yield))) async def f(): await some.complicated[0].call(with_args=(True or (1 is not 1))) Loading Loading @@ -458,7 +460,9 @@ async def f(): def gen(): yield from outside_of_generator a = (yield) a = yield b = yield c = yield async def f(): Loading Loading
black.py +4 −4 Changes for black.py: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2728,7 +2728,7 @@ def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None: for index, child in enumerate(list(node.children)): if check_lpar: if child.type == syms.atom: if maybe_make_parens_invisible_in_atom(child): if maybe_make_parens_invisible_in_atom(child, parent=node): lpar = Leaf(token.LPAR, "") rpar = Leaf(token.RPAR, "") index = child.remove() or 0 Loading Loading @@ -2839,7 +2839,7 @@ def generate_ignored_nodes(leaf: Leaf) -> Iterator[LN]: container = container.next_sibling def maybe_make_parens_invisible_in_atom(node: LN) -> bool: def maybe_make_parens_invisible_in_atom(node: LN, parent: LN) -> bool: """If it's safe, make the parens in the atom `node` invisible, recursively. Returns whether the node should itself be wrapped in invisible parentheses. Loading @@ -2849,7 +2849,7 @@ def maybe_make_parens_invisible_in_atom(node: LN) -> bool: node.type != syms.atom or is_empty_tuple(node) or is_one_tuple(node) or is_yield(node) or (is_yield(node) and parent.type != syms.expr_stmt) or max_delimiter_priority_in_atom(node) >= COMMA_PRIORITY ): return False Loading @@ -2861,7 +2861,7 @@ def maybe_make_parens_invisible_in_atom(node: LN) -> bool: first.value = "" # type: ignore last.value = "" # type: ignore if len(node.children) > 1: maybe_make_parens_invisible_in_atom(node.children[1]) maybe_make_parens_invisible_in_atom(node.children[1], parent=parent) return False return True Loading
tests/data/expression.diff +8 −3 Changes for tests/data/expression.diff: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -147,7 +147,7 @@ slice[0:1:2] slice[:] slice[:-1] @@ -133,111 +156,169 @@ @@ -133,113 +156,171 @@ numpy[-(c + 1) :, d] numpy[:, l[-2]] numpy[:, ::-1] Loading Loading @@ -214,9 +214,14 @@ + def gen(): yield from outside_of_generator a = (yield) - a = (yield) - b = ((yield)) - c = (((yield))) + a = yield + b = yield + c = yield + async def f(): await some.complicated[0].call(with_args=(True or (1 is not 1))) -print(* [] or [1]) Loading
tests/data/expression.py +5 −1 Changes for tests/data/expression.py: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -169,6 +169,8 @@ def gen(): yield from outside_of_generator a = (yield) b = ((yield)) c = (((yield))) async def f(): await some.complicated[0].call(with_args=(True or (1 is not 1))) Loading Loading @@ -458,7 +460,9 @@ async def f(): def gen(): yield from outside_of_generator a = (yield) a = yield b = yield c = yield async def f(): Loading