Skip to content

Commit dc1a1ac

Browse files
committed
Apply proper formatting to the changes
1 parent 9cdfc20 commit dc1a1ac

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

yapf/yapflib/format_decision_state.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ def SurroundedByParens(token):
560560
if style.Get('SPLIT_ALL_LOGICAL_OPERATORS_IF_ANY_SPLIT'):
561561
split_before = style.Get("SPLIT_BEFORE_LOGICAL_OPERATOR")
562562
check_token = current if split_before else current.previous_token
563-
if (check_token and check_token.name == "NAME" and check_token.value in logical_line._LOGICAL_OPERATORS):
563+
if (check_token and check_token.name == "NAME" and
564+
check_token.value in logical_line._LOGICAL_OPERATORS):
564565
opening = _GetOpeningBracket(check_token)
565566
if opening:
566567
ending = opening.matching_bracket
@@ -572,9 +573,9 @@ def SurroundedByParens(token):
572573
next_token = ending.next_token
573574
prev_token = opening.previous_token
574575
if split_before:
575-
if prev_token:
576-
clause_start = _PrevLogicalClause(prev_token)
577-
length += opening.total_length - clause_start.total_length
576+
if prev_token:
577+
clause_start = _PrevLogicalClause(prev_token)
578+
length += opening.total_length - clause_start.total_length
578579
else:
579580
if next_token:
580581
clause_end = _NextLogicalClause(next_token)

yapf/yapflib/logical_line.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,17 +616,19 @@ def _SplitPenalty(prev_token, cur_token):
616616

617617
if logical_splitting:
618618
if style.Get('SPLIT_BEFORE_LOGICAL_OPERATOR'):
619-
# Prefer to split before 'and' and 'or'.
620-
if pval in _LOGICAL_OPERATORS:
621-
return max(node_split_penalty, style.Get('SPLIT_PENALTY_LOGICAL_OPERATOR'))
622-
if cval in _LOGICAL_OPERATORS:
623-
return max(node_split_penalty, 0)
619+
# Prefer to split before 'and' and 'or'.
620+
if pval in _LOGICAL_OPERATORS:
621+
return max(node_split_penalty,
622+
style.Get('SPLIT_PENALTY_LOGICAL_OPERATOR'))
623+
if cval in _LOGICAL_OPERATORS:
624+
return max(node_split_penalty, 0)
624625
else:
625626
# Prefer to split after 'and' and 'or'.
626627
if pval in _LOGICAL_OPERATORS:
627628
return max(node_split_penalty, 0)
628629
if cval in _LOGICAL_OPERATORS:
629-
return max(node_split_penalty, style.Get('SPLIT_PENALTY_LOGICAL_OPERATOR'))
630+
return max(node_split_penalty,
631+
style.Get('SPLIT_PENALTY_LOGICAL_OPERATOR'))
630632

631633
if node_split_penalty > 0:
632634
return node_split_penalty

0 commit comments

Comments
 (0)