Loading README.md +5 −0 Changes for README.md: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -293,6 +293,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). ## Change Log ### 18.3a4 (unreleased) * don't omit whitespace if the previous factor leaf wasn't a math operator (#55) ### 18.3a3 * don't remove single empty lines outside of bracketed expressions Loading black.py +6 −1 Changes for black.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -340,6 +340,7 @@ def visit_default(self, node: LN) -> Iterator[T]: token.AMPER, token.PERCENT, token.CIRCUMFLEX, token.TILDE, token.LEFTSHIFT, token.RIGHTSHIFT, token.DOUBLESTAR, Loading Loading @@ -888,7 +889,11 @@ def whitespace(leaf: Leaf) -> str: # noqa C901 if prevp.parent and prevp.parent.type in {syms.subscript, syms.sliceop}: return NO elif prevp.parent and prevp.parent.type in {syms.factor, syms.star_expr}: elif ( prevp.parent and prevp.parent.type in {syms.factor, syms.star_expr} and prevp.type in MATH_OPERATORS ): return NO elif prev.type in OPENING_BRACKETS: Loading tests/expression.py +4 −0 Changes for tests/expression.py: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)] {i: 0 for i in (1, 2, 3)} {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))} {a: b * 2 for a, b in dictionary.items()} {a: b * -2 for a, b in dictionary.items()} {k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} Python3 > Python2 > COBOL Life is Life Loading Loading @@ -214,6 +216,8 @@ async def f(): [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)] {i: 0 for i in (1, 2, 3)} {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))} {a: b * 2 for a, b in dictionary.items()} {a: b * -2 for a, b in dictionary.items()} { k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension Loading Loading
README.md +5 −0 Changes for README.md: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -293,6 +293,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). ## Change Log ### 18.3a4 (unreleased) * don't omit whitespace if the previous factor leaf wasn't a math operator (#55) ### 18.3a3 * don't remove single empty lines outside of bracketed expressions Loading
black.py +6 −1 Changes for black.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -340,6 +340,7 @@ def visit_default(self, node: LN) -> Iterator[T]: token.AMPER, token.PERCENT, token.CIRCUMFLEX, token.TILDE, token.LEFTSHIFT, token.RIGHTSHIFT, token.DOUBLESTAR, Loading Loading @@ -888,7 +889,11 @@ def whitespace(leaf: Leaf) -> str: # noqa C901 if prevp.parent and prevp.parent.type in {syms.subscript, syms.sliceop}: return NO elif prevp.parent and prevp.parent.type in {syms.factor, syms.star_expr}: elif ( prevp.parent and prevp.parent.type in {syms.factor, syms.star_expr} and prevp.type in MATH_OPERATORS ): return NO elif prev.type in OPENING_BRACKETS: Loading
tests/expression.py +4 −0 Changes for tests/expression.py: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)] {i: 0 for i in (1, 2, 3)} {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))} {a: b * 2 for a, b in dictionary.items()} {a: b * -2 for a, b in dictionary.items()} {k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} Python3 > Python2 > COBOL Life is Life Loading Loading @@ -214,6 +216,8 @@ async def f(): [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)] {i: 0 for i in (1, 2, 3)} {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))} {a: b * 2 for a, b in dictionary.items()} {a: b * -2 for a, b in dictionary.items()} { k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension Loading