Skip to content

Commit

Permalink
Simplify the conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-sony committed Oct 18, 2023
1 parent dc1a1ac commit fe92eeb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions yapf/yapflib/format_decision_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,12 @@ def SurroundedByParens(token):
# length because we might wrap after it
next_token = ending.next_token
prev_token = opening.previous_token
if split_before:
if prev_token:
clause_start = _PrevLogicalClause(prev_token)
length += opening.total_length - clause_start.total_length
else:
if next_token:
clause_end = _NextLogicalClause(next_token)
length += clause_end.total_length - ending.total_length
if split_before and prev_token:
clause_start = _PrevLogicalClause(prev_token)
length += opening.total_length - clause_start.total_length
elif not split_before and next_token
clause_end = _NextLogicalClause(next_token)
length += clause_end.total_length - ending.total_length
else:
end_token = _LastTokenInLine(check_token)
length = end_token.total_length + self.stack[-1].indent
Expand Down

0 comments on commit fe92eeb

Please sign in to comment.