Skip to content

Commit

Permalink
Merge pull request #418 from njsmith/patch-1
Browse files Browse the repository at this point in the history
Update PEP 8 style to match modern PEP 8
  • Loading branch information
bwendling committed Jul 13, 2017
2 parents bac6ef4 + e3b1e9f commit 7b5b976
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions yapf/yapflib/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ def CreatePEP8Style():
SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN=False,
SPACES_BEFORE_COMMENT=2,
SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED=False,
SPLIT_BEFORE_BITWISE_OPERATOR=False,
SPLIT_BEFORE_BITWISE_OPERATOR=True,
SPLIT_BEFORE_DICT_SET_GENERATOR=True,
SPLIT_BEFORE_FIRST_ARGUMENT=False,
SPLIT_BEFORE_LOGICAL_OPERATOR=False,
SPLIT_BEFORE_LOGICAL_OPERATOR=True,
SPLIT_BEFORE_NAMED_ASSIGNS=True,
SPLIT_PENALTY_AFTER_OPENING_BRACKET=30,
SPLIT_PENALTY_AFTER_UNARY_OPERATOR=10000,
Expand All @@ -244,6 +244,8 @@ def CreateGoogleStyle():
style['I18N_COMMENT'] = r'#\..*'
style['I18N_FUNCTION_CALL'] = ['N_', '_']
style['SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET'] = False
style['SPLIT_BEFORE_LOGICAL_OPERATOR'] = False
style['SPLIT_BEFORE_BITWISE_OPERATOR'] = False
return style


Expand All @@ -267,6 +269,8 @@ def CreateFacebookStyle():
style['SPLIT_PENALTY_AFTER_OPENING_BRACKET'] = 0
style['SPLIT_PENALTY_BEFORE_IF_EXPR'] = 30
style['SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT'] = 30
style['SPLIT_BEFORE_LOGICAL_OPERATOR'] = False
style['SPLIT_BEFORE_BITWISE_OPERATOR'] = False
return style


Expand Down
12 changes: 6 additions & 6 deletions yapftests/reformatter_pep8_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def g():
expected_formatted_code = textwrap.dedent("""\
def f():
def g():
while (xxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa' and
xxxxxxxxxxxxxxxxxxxx(
while (xxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa'
and xxxxxxxxxxxxxxxxxxxx(
yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'):
pass
""")
Expand Down Expand Up @@ -205,8 +205,8 @@ def h():
dosomething(connection)
""")
expected_formatted_code = textwrap.dedent("""\
if (aaaaaaaaaaaaaa + bbbbbbbbbbbbbbbb == ccccccccccccccccc and xxxxxxxxxxxxx or
yyyyyyyyyyyyyyyyy):
if (aaaaaaaaaaaaaa + bbbbbbbbbbbbbbbb == ccccccccccccccccc and xxxxxxxxxxxxx
or yyyyyyyyyyyyyyyyy):
pass
elif (xxxxxxxxxxxxxxx(
aaaaaaaaaaa, bbbbbbbbbbbbbb, cccccccccccc, dddddddddd=None)):
Expand Down Expand Up @@ -303,8 +303,8 @@ def foo():
""")
expected_formatted_code = textwrap.dedent("""\
def foo():
df = df[(df['campaign_status'] == 'LIVE') &
(df['action_status'] == 'LIVE')]
df = df[(df['campaign_status'] == 'LIVE')
& (df['action_status'] == 'LIVE')]
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
Expand Down

0 comments on commit 7b5b976

Please sign in to comment.