Skip to content

Commit

Permalink
Merge 38223d9 into da0dbb3
Browse files Browse the repository at this point in the history
  • Loading branch information
bouweandela committed Aug 20, 2021
2 parents da0dbb3 + 38223d9 commit c08a4a4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions yapf/yapflib/style.py
Expand Up @@ -418,7 +418,7 @@ def CreatePEP8Style():
ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS=True,
ALLOW_SPLIT_BEFORE_DICT_VALUE=True,
ARITHMETIC_PRECEDENCE_INDICATION=False,
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=False,
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=True,
BLANK_LINE_BEFORE_CLASS_DOCSTRING=False,
BLANK_LINE_BEFORE_MODULE_DOCSTRING=False,
BLANK_LINES_AROUND_TOP_LEVEL_DEFINITION=2,
Expand Down Expand Up @@ -479,7 +479,6 @@ def CreateGoogleStyle():
"""Create the Google formatting style."""
style = CreatePEP8Style()
style['ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT'] = False
style['BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF'] = True
style['COLUMN_LIMIT'] = 80
style['INDENT_DICTIONARY_VALUE'] = True
style['INDENT_WIDTH'] = 4
Expand Down Expand Up @@ -511,6 +510,7 @@ def CreateFacebookStyle():
"""Create the Facebook formatting style."""
style = CreatePEP8Style()
style['ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT'] = False
style['BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF'] = False
style['COLUMN_LIMIT'] = 80
style['DEDENT_CLOSING_BRACKETS'] = True
style['INDENT_CLOSING_BRACKETS'] = False
Expand Down
1 change: 1 addition & 0 deletions yapftests/reformatter_basic_test.py
Expand Up @@ -1982,6 +1982,7 @@ def testMultilineDictionaryKeys(self):
def testStableDictionaryFormatting(self):
code = textwrap.dedent("""\
class A(object):
def method(self):
filters = {
'expressions': [{
Expand Down
12 changes: 9 additions & 3 deletions yapftests/reformatter_pep8_test.py
Expand Up @@ -50,22 +50,22 @@ def testSingleLineIfStatements(self):
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))

def testNoBlankBetweenClassAndDef(self):
def testBlankBetweenClassAndDef(self):
unformatted_code = textwrap.dedent("""\
class Foo:
def joe():
pass
""")
expected_formatted_code = textwrap.dedent("""\
class Foo:
def joe():
pass
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))

def testNoBlankBetweenDefsInClass(self):
def testBlankBetweenDefsInClass(self):
unformatted_code = textwrap.dedent('''\
class TestClass:
def __init__(self):
Expand All @@ -77,6 +77,7 @@ def is_running(self):
''')
expected_formatted_code = textwrap.dedent('''\
class TestClass:
def __init__(self):
self.running = False
Expand Down Expand Up @@ -174,6 +175,7 @@ def g():
""")
expected_formatted_code = textwrap.dedent("""\
def f():
def g():
while (xxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa'
and xxxxxxxxxxxxxxxxxxxx(
Expand Down Expand Up @@ -341,11 +343,13 @@ def testSplitListsAndDictSetMakersIfCommaTerminated(self):
def testSplitAroundNamedAssigns(self):
unformatted_code = textwrap.dedent("""\
class a():
def a(): return a(
aaaaaaaaaa=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
""")
expected_formatted_code = textwrap.dedent("""\
class a():
def a():
return a(
aaaaaaaaaa=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Expand Down Expand Up @@ -501,6 +505,7 @@ class Demo:
"""
Demo docs
"""
def foo(self):
"""
foo docs
Expand Down Expand Up @@ -602,6 +607,7 @@ def __init__(self, title: Optional[str], diffs: Collection[BinaryDiff] = (), cha
""")
expected_formatted_code = textwrap.dedent("""\
class _():
def __init__(
self,
title: Optional[str],
Expand Down
2 changes: 2 additions & 0 deletions yapftests/reformatter_python3_test.py
Expand Up @@ -238,6 +238,7 @@ def testAsyncFunctionsNested(self):
return
code = textwrap.dedent("""\
async def outer():
async def inner():
pass
""")
Expand Down Expand Up @@ -365,6 +366,7 @@ def foo(self):
"""
expected_formatted_code = """\
class Foo:
def foo(self):
foofoofoofoofoofoofoofoo('foofoofoofoofoo', {
'foo': 'foo',
Expand Down
2 changes: 2 additions & 0 deletions yapftests/yapf_test.py
Expand Up @@ -735,12 +735,14 @@ def testDisableWholeDataStructure(self):
def testDisableButAdjustIndentations(self):
unformatted_code = textwrap.dedent("""\
class SplitPenaltyTest(unittest.TestCase):
def testUnbreakable(self):
self._CheckPenalties(tree, [
]) # yapf: disable
""")
expected_formatted_code = textwrap.dedent("""\
class SplitPenaltyTest(unittest.TestCase):
def testUnbreakable(self):
self._CheckPenalties(tree, [
]) # yapf: disable
Expand Down

0 comments on commit c08a4a4

Please sign in to comment.