diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py index 1a6daddcb..308fd75b9 100644 --- a/yapf/yapflib/format_decision_state.py +++ b/yapf/yapflib/format_decision_state.py @@ -575,7 +575,7 @@ def SurroundedByParens(token): 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 + elif not split_before and next_token: clause_end = _NextLogicalClause(next_token) length += clause_end.total_length - ending.total_length else: