Skip to content

Commit

Permalink
Increase penalty for excess characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bwendling committed Mar 31, 2017
1 parent 77ca21d commit e67e353
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Treat expansion operators ('*', '**') in a similar way to function calls to
avoid splitting directly after the opening parenthesis.
- Increase the penalty for splitting after the start of a tuple.
- Increase penalty for excess characters.

## [0.16.1] 2017-03-22
### Changed
Expand Down
2 changes: 1 addition & 1 deletion yapf/yapflib/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def CreatePEP8Style():
SPLIT_PENALTY_AFTER_UNARY_OPERATOR=10000,
SPLIT_PENALTY_BEFORE_IF_EXPR=0,
SPLIT_PENALTY_BITWISE_OPERATOR=300,
SPLIT_PENALTY_EXCESS_CHARACTER=3500,
SPLIT_PENALTY_EXCESS_CHARACTER=4500,
SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT=30,
SPLIT_PENALTY_IMPORT_NAMES=0,
SPLIT_PENALTY_LOGICAL_OPERATOR=300,
Expand Down
18 changes: 18 additions & 0 deletions yapftests/reformatter_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,24 @@ def bar(self):
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))

unformatted_code = textwrap.dedent("""\
def _():
if True:
if True:
if contract == allow_contract and attr_dict.get(if_attribute) == has_value:
return True
""")
expected_code = textwrap.dedent("""\
def _():
if True:
if True:
if contract == allow_contract and attr_dict.get(
if_attribute) == has_value:
return True
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertEqual(expected_code, reformatter.Reformat(uwlines))

def testDictSetGenerator(self):
code = textwrap.dedent("""\
foo = {
Expand Down

0 comments on commit e67e353

Please sign in to comment.