yapf
yapf copied to clipboard
`split_before_arithmetic_operator` is ignored?
Despite this simple config file:
[style]
based_on_style = pep8
split_before_arithmetic_operator = true
yapf splits after the operator, not before as it should:
% ~/.local/bin/yapf --diff --style op.yapf op.py
--- op.py (original)
+++ op.py (reformatted)
@@ -1 +1,3 @@
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccccccccccccccccccccccccc)
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
+ cccccccccccccccccccccccccccccccccccccccccccccc)
SPLIT_BEFORE_ARITHMETIC_OPERATOR
Set to True to prefer splitting before +, -, *, /, //, or @ rather than after.
Works fine for me with yapf 0.29.0
.
I don't know if it could be a version problem, but I leave it as a background.
Have the same issue in 0.30.0. Also it seems missing *, / and //
_ARITH_OPS = frozenset({'PLUS', 'MINUS'})
def Visit_arith_expr(self, node): # pylint: disable=invalid-name
# arith_expr ::= term (('+'|'-') term)*
self.DefaultNodeVisit(node)
_IncreasePenalty(node, ARITH_EXPR)
_SetExpressionOperandPenalty(node, self._ARITH_OPS)
The '*', '/', '@', and '//' operators are taken care of in Visit_term
.