Add more files to flake8 run.

pull/776/merge
Bill Wendling 11 months ago
parent 82ebfca90d
commit 9d6808a3d9
  1. 6
      .flake8
  2. 8
      yapf/yapflib/py3compat.py
  3. 2
      yapftests/blank_line_calculator_test.py
  4. 2
      yapftests/file_resources_test.py
  5. 2
      yapftests/line_joiner_test.py
  6. 147
      yapftests/reformatter_basic_test.py
  7. 154
      yapftests/reformatter_buganizer_test.py
  8. 28
      yapftests/reformatter_facebook_test.py
  9. 46
      yapftests/reformatter_pep8_test.py
  10. 12
      yapftests/reformatter_python3_test.py
  11. 2
      yapftests/reformatter_style_config_test.py
  12. 82
      yapftests/yapf_test.py
  13. 16
      yapftests/yapf_test_helper.py

@ -1,5 +1,7 @@
[flake8]
ignore =
# 'toml' imported but unused
F401,
# closing bracket does not match visual indentation
E124,
# continuation line over-indented for hanging indent
@ -11,10 +13,6 @@ ignore =
# line break after binary operator
W504
exclude =
yapf/yapflib/py3compat.py
yapftests/*
disable-noqa
indent-size = 2
max-line-length = 80

@ -27,9 +27,9 @@ if PY3:
StringIO = io.StringIO
BytesIO = io.BytesIO
import codecs
import codecs # noqa: F811
def open_with_encoding(filename, mode, encoding, newline=''): # pylint: disable=unused-argument
def open_with_encoding(filename, mode, encoding, newline=''): # pylint: disable=unused-argument # noqa
return codecs.open(filename, mode=mode, encoding=encoding)
import functools
@ -62,13 +62,13 @@ else:
return fake_wrapper
range = xrange
range = xrange # noqa: F821
from itertools import ifilter
raw_input = raw_input
import ConfigParser as configparser
CONFIGPARSER_BOOLEAN_STATES = configparser.ConfigParser._boolean_states # pylint: disable=protected-access
CONFIGPARSER_BOOLEAN_STATES = configparser.ConfigParser._boolean_states # pylint: disable=protected-access # noqa
def EncodeAndWriteToStdout(s, encoding='utf-8'):

@ -249,7 +249,7 @@ class BasicBlankLineCalculatorTest(yapf_test_helper.YAPFTest):
# reason="https://github.com/pypa/setuptools/issues/706")
def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch):
pass
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))

@ -525,7 +525,7 @@ class WriteReformattedCodeTest(unittest.TestCase):
self.assertEqual(stream.getvalue(), s)
def test_write_encoded_to_stdout(self):
s = '\ufeff# -*- coding: utf-8 -*-\nresult = "passed"\n' # pylint: disable=anomalous-unicode-escape-in-string
s = '\ufeff# -*- coding: utf-8 -*-\nresult = "passed"\n' # pylint: disable=anomalous-unicode-escape-in-string # noqa
stream = BufferedByteStream() if py3compat.PY3 else py3compat.StringIO()
with utils.stdout_redirector(stream):
file_resources.WriteReformattedCode(

@ -74,7 +74,7 @@ class LineJoinerTest(yapf_test_helper.YAPFTest):
def testOverColumnLimit(self):
code = textwrap.dedent(u"""\
if instance(bbbbbbbbbbbbbbbbbbbbbbbbb, int): cccccccccccccccccccccccccc = ddddddddddddddddddddd
""")
""") # noqa
self._CheckLineJoining(code, join_lines=False)

@ -35,7 +35,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
'{split_all_comma_separated_values: true, column_limit: 40}'))
unformatted_code = textwrap.dedent("""\
responseDict = {"timestamp": timestamp, "someValue": value, "whatever": 120}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
responseDict = {
"timestamp": timestamp,
@ -60,7 +60,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
unformatted_code = textwrap.dedent("""\
def foo(long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def foo(long_arg,
really_long_arg,
@ -72,7 +72,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
unformatted_code = textwrap.dedent("""\
foo_tuple = [long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args]
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
foo_tuple = [
long_arg,
@ -109,12 +109,13 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
def testSplittingTopLevelAllArgs(self):
style.SetGlobalStyle(
style.CreateStyleFromConfig(
'{split_all_top_level_comma_separated_values: true, column_limit: 40}'
'{split_all_top_level_comma_separated_values: true, '
'column_limit: 40}'
))
# Works the same way as split_all_comma_separated_values
unformatted_code = textwrap.dedent("""\
responseDict = {"timestamp": timestamp, "someValue": value, "whatever": 120}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
responseDict = {
"timestamp": timestamp,
@ -128,7 +129,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
unformatted_code = textwrap.dedent("""\
def foo(long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def foo(long_arg,
really_long_arg,
@ -141,7 +142,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
# Works the same way as split_all_comma_separated_values
unformatted_code = textwrap.dedent("""\
foo_tuple = [long_arg, really_long_arg, really_really_long_arg, cant_keep_all_these_args]
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
foo_tuple = [
long_arg,
@ -280,7 +281,8 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
try:
style.SetGlobalStyle(
style.CreateStyleFromConfig(
'{based_on_style: yapf, blank_lines_between_top_level_imports_and_variables: 2}'
'{based_on_style: yapf, '
'blank_lines_between_top_level_imports_and_variables: 2}'
))
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code,
@ -390,7 +392,7 @@ class BasicReformatterTest(yapf_test_helper.YAPFTest):
""")
expected_formatted_code = """\
class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(self, x, y): # bar\n \n if x:\n \n return y\n\n\ndef bar():\n \n return 0
"""
""" # noqa
try:
style.SetGlobalStyle(
@ -510,9 +512,7 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def testCommentsWithTrailingSpaces(self):
unformatted_code = textwrap.dedent("""\
# Thing 1
# Thing 2
""")
# Thing 1 \n# Thing 2 \n""")
expected_formatted_code = textwrap.dedent("""\
# Thing 1
# Thing 2
@ -694,7 +694,7 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def f():
assert port >= minimum, 'Unexpected port %d when minimum was %d.' % (port,
minimum)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -772,7 +772,7 @@ class foo(object):\n \n def foobar(self):\n \n pass\n \n def barfoo(se
def given(used_identifiers):
return (sum(len(identifier)
for identifier in used_identifiers) / len(used_identifiers))
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def given(used_identifiers):
return (sum(len(identifier) for identifier in used_identifiers) /
@ -853,7 +853,7 @@ foo((
# one are then splatted at the end of the line with no formatting.
unformatted_code = """\
find_symbol(node.type) + "< " + " ".join(find_pattern(n) for n in node.child) + " >"
"""
""" # noqa
expected_formatted_code = """\
find_symbol(node.type) + "< " + " ".join(
find_pattern(n) for n in node.child) + " >"
@ -918,7 +918,7 @@ find_symbol(node.type) + "< " + " ".join(
'yield_stmt': 'import_stmt', lambda: 'global_stmt': 'exec_stmt', 'assert_stmt':
'if_stmt', 'while_stmt': 'for_stmt',
})
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
_PYTHON_STATEMENTS = frozenset({
lambda x, y: 'simple_stmt': 'small_stmt',
@ -949,7 +949,7 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
vvvvvvvvv)
aaaaaaaaaaaaaa.bbbbbbbbbbbbbb.ccccccc(zzzzzzzzzzzz, xxxxxxxxxxx, yyyyyyyyyyyy,
vvvvvvvvv)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -996,7 +996,7 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
<b>Residence: </b>"""+palace["Winter"]+"""<br>
</body>
</html>"""
''')
''') # noqa
expected_formatted_code = textwrap.dedent('''\
def f():
email_text += """<html>This is a really long docstring that goes over the column limit and is multi-line.<br><br>
@ -1005,7 +1005,7 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
<b>Residence: </b>""" + palace["Winter"] + """<br>
</body>
</html>"""
''')
''') # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1057,7 +1057,7 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
child,
subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(child.value,
format_token.Subtype.NONE))
''')
''') # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1082,13 +1082,13 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
def testI18n(self):
code = textwrap.dedent("""\
N_('Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.') # A comment is here.
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
code = textwrap.dedent("""\
foo('Fake function call') #. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1115,7 +1115,7 @@ xxxxxxxxxxx, yyyyyyyyyyyy, vvvvvvvvv)
xxxxxxxxxxxxxxxxxxxxx(
yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'):
pass
''')
''') # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1186,7 +1186,7 @@ class foo:
#. Error message indicating an invalid e-mail address.
message=N_('Please check your email address.'), **kwargs):
pass
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1356,7 +1356,7 @@ class foo:
expected_formatted_code = textwrap.dedent("""\
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = aaaaaaaaaaa(
("...", "."), "..", "..............................................")
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1390,7 +1390,7 @@ class foo:
pass
except:
pass
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1436,14 +1436,14 @@ urlpatterns = patterns('', url(r'^$', 'homepage_view'),
"ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis "\\
"sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. "\\
"Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet"
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
code = textwrap.dedent("""\
from __future__ import nested_scopes, generators, division, absolute_import, with_statement, \\
print_function, unicode_literals
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1490,14 +1490,14 @@ s = 'foo \\
'output_dirs', [],
'Lorem ipsum dolor sit amet, consetetur adipiscing elit. Donec a diam lectus. '
'Sed sit amet ipsum mauris. Maecenas congue.')
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
def testSplitStringsIfSurroundedByParens(self):
unformatted_code = textwrap.dedent("""\
a = foo.bar({'xxxxxxxxxxxxxxxxxxxxxxx' 'yyyyyyyyyyyyyyyyyyyyyyyyyy': baz[42]} + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbbbbbbbbbbbbbbbbb' 'cccccccccccccccccccccccccccccccc' 'ddddddddddddddddddddddddddddd')
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
a = foo.bar({'xxxxxxxxxxxxxxxxxxxxxxx'
'yyyyyyyyyyyyyyyyyyyyyyyyyy': baz[42]} +
@ -1563,7 +1563,7 @@ s = 'foo \\
self.write(s=[
'%s%s %s' % ('many of really', 'long strings', '+ just makes up 81')
])
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1573,7 +1573,7 @@ s = 'foo \\
if True:
if contract == allow_contract and attr_dict.get(if_attribute) == has_value:
return True
""")
""") # noqa
expected_code = textwrap.dedent("""\
def _():
if True:
@ -1615,7 +1615,7 @@ s = 'foo \\
if True:
remote_checksum = self.get_checksum(conn, tmp, dest, inject,
not directory_prepended, source)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1650,7 +1650,7 @@ class A(object):
def test():
if not "Foooooooooooooooooooooooooooooo" or "Foooooooooooooooooooooooooooooo" == "Foooooooooooooooooooooooooooooo":
pass
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1675,7 +1675,7 @@ class A(object):
('aaaaaaaaaaaaa', 'bbbb'): 'ccccccccccccccccccccccccccccccccccccccccccc',
('aaaaaaaaaaaaa', 'bbbb'): 'ccccccccccccccccccccccccccccccccccccccccccc',
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class Test:
@ -1698,7 +1698,7 @@ class A(object):
a="something",
b="something requiring comment which is quite long", # comment about b (pushes line over 79)
c="something else, about which comment doesn't make sense")
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1752,7 +1752,7 @@ class A(object):
if True:
if True:
status = cf.describe_stacks(StackName=stackname)[u'Stacks'][0][u'StackStatus']
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
if True:
if True:
@ -1780,7 +1780,7 @@ class A(object):
xxxxxxxxxxxxxx = (
re.search(r'(\\d+\\.\\d+\\.\\d+\\.)\\d+', aaaaaaa.bbbbbbbbbbbb).group(a.b) +
re.search(r'\\d+\\.\\d+\\.\\d+\\.(\\d+)', ccccccc).group(c.d))
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1790,7 +1790,7 @@ class A(object):
while True:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = list['bbbbbbbbbbbbbbbbbbbbbbbbb'].split(',')
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = list('bbbbbbbbbbbbbbbbbbbbbbbbb').split(',')
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
while True:
while True:
@ -1808,14 +1808,14 @@ class A(object):
def __repr__(self):
tokens_repr = ','.join(['{0}({1!r})'.format(tok.name, tok.value) for tok in self._tokens])
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class f:
def __repr__(self):
tokens_repr = ','.join(
['{0}({1!r})'.format(tok.name, tok.value) for tok in self._tokens])
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1840,7 +1840,7 @@ class A(object):
pytree_utils.InsertNodesBefore(
_CreateCommentsFromPrefix(
comment_prefix, comment_lineno, comment_column, standalone=True))
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1872,7 +1872,7 @@ class A(object):
code = textwrap.dedent("""\
[retval1, retval2] = a_very_long_function(argument_1, argument2, argument_3,
argument_4)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1922,7 +1922,7 @@ class A(object):
if self.do_something:
d.addCallback(lambda _: self.aaaaaa.bbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccccccc(dddddddddddddd))
return d
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class SomeClass(object):
do_something = True
@ -1956,7 +1956,7 @@ class A(object):
('vehicula convallis nulla. Vestibulum dictum nisl in malesuada finibus.',):
3
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
MAP_WITH_LONG_KEYS = {
('lorem ipsum', 'dolor sit amet'):
@ -1967,7 +1967,7 @@ class A(object):
('vehicula convallis nulla. Vestibulum dictum nisl in malesuada finibus.',):
3
}
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -1993,13 +1993,14 @@ class A(object):
}
}]
}
""")
""") # noqa
try:
style.SetGlobalStyle(
style.CreateStyleFromConfig(
'{based_on_style: pep8, indent_width: 2, '
'continuation_indent_width: 4, indent_dictionary_value: True}'))
'continuation_indent_width: 4, '
'indent_dictionary_value: True}'))
uwlines = yapf_test_helper.ParseAndUnwrap(code)
reformatted_code = reformatter.Reformat(uwlines)
@ -2018,7 +2019,7 @@ class A(object):
def _():
url = "http://{0}/axis-cgi/admin/param.cgi?{1}".format(
value, urllib.urlencode({'action': 'update', 'parameter': value}))
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
url = "http://{0}/axis-cgi/admin/param.cgi?{1}".format(
@ -2072,7 +2073,7 @@ class A(object):
x for x, y in self._heap_this_is_very_long if x.route[0] == choice
]
self._heap = [x for x in self._heap if x.route and x.route[0] == choice]
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -2089,7 +2090,7 @@ class A(object):
long_argument_name_1=1, long_argument_name_2=2, long_argument_name_3=3,
long_argument_name_4=4
)
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -2132,7 +2133,7 @@ class A(object):
if True:
if True:
boxes[id_] = np.concatenate((points.min(axis=0), qoints.max(axis=0)))
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
if True:
@ -2159,7 +2160,7 @@ class A(object):
clue for clue in combination if not clue == Verifier.UNMATCHED
), constraints, InvestigationResult.OR
)
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class _():
@ -2171,7 +2172,7 @@ class A(object):
return cls._create_investigation_result(
(clue for clue in combination if not clue == Verifier.UNMATCHED),
constraints, InvestigationResult.OR)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -2186,7 +2187,7 @@ class A(object):
a_very_long_function_name(long_argument_name_1, long_argument_name_2, long_argument_name_3, long_argument_name_4,)
r =f0 (1, 2,3,)
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
function_name(argument_name_1=1, argument_name_2=2, argument_name_3=3)
@ -2289,7 +2290,7 @@ class A(object):
'jjjjjjjjjjjjjjjjjjjjjjjjjj':
Check('QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ', '=', False),
}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -2303,7 +2304,7 @@ class A(object):
expected_formatted_code = textwrap.dedent("""\
doc = test_utils.CreateTestDocumentViaController(
content={'a': 'b'}, branch_key=branch.key, collection_key=collection.key)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -2353,7 +2354,7 @@ class A(object):
'cccccccccc': ('^21109', # PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP.
),
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
_A = {
'cccccccccc': ('^^1',),
@ -2415,7 +2416,7 @@ class A(object):
},
]
breadcrumbs = [{'name': 'Admin', 'url': url_for(".home")}, {'title': title}]
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -2435,18 +2436,18 @@ class A(object):
Environment.YYYYYYY: 'some text more text even more text yet ag',
Environment.ZZZZZZZZZZZ: 'some text more text even more text yet again tex',
}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
def testNotInParams(self):
unformatted_code = textwrap.dedent("""\
list("a long line to break the line. a long line to break the brk a long lin", not True)
""")
""") # noqa
expected_code = textwrap.dedent("""\
list("a long line to break the line. a long line to break the brk a long lin",
not True)
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_code, reformatter.Reformat(uwlines))
@ -2834,7 +2835,7 @@ my_dict = {
def function(first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_argument=None) -> None:
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function(
first_argument_xxxxxxxxxxxxxxxx=(0,), second_argument=None
@ -2846,7 +2847,7 @@ my_dict = {
first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_argument=None
) -> None:
pass
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -2867,7 +2868,7 @@ my_dict = {
def function(first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_argument=None) -> None:
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function(
first_argument_xxxxxxxxxxxxxxxx=(0,), second_argument=None
@ -2879,7 +2880,7 @@ my_dict = {
first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_argument=None
) -> None:
pass
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -2900,7 +2901,7 @@ my_dict = {
def function(first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_and_last_argument=None):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function(
first_argument_xxxxxxxxxxxxxxxx=(0,),
@ -2914,7 +2915,7 @@ my_dict = {
first_argument_xxxxxxxxxxxxxxxxxxxxxxx=(0,), second_and_last_argument=None
):
pass
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -2936,7 +2937,7 @@ my_dict = {
def function():
some_var = ('a couple', 'small', 'elemens')
return False
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function():
some_var = (
@ -2949,7 +2950,7 @@ my_dict = {
def function():
some_var = ('a couple', 'small', 'elemens')
return False
""")
""") # noqa
try:
style.SetGlobalStyle(
@ -2971,7 +2972,7 @@ my_dict = {
def function():
some_var = ['a couple', 'small', 'elemens']
return False
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function():
some_var = [
@ -3006,7 +3007,7 @@ my_dict = {
def function():
some_var = {1: 'a couple', 2: 'small', 3: 'elemens'}
return False
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def function():
some_var = {
@ -3025,7 +3026,7 @@ my_dict = {
def function():
some_var = {1: 'a couple', 2: 'small', 3: 'elemens'}
return False
""")
""") # noqa
try:
style.SetGlobalStyle(

@ -170,7 +170,7 @@ class _():
'PyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyType' # pytype: disable=attribute-error
'CopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybara' # copybara:strip
)
"""
""" # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -203,7 +203,7 @@ X = {
class Foo(object):
def testNoAlertForShortPeriod(self, rutabaga):
self.targets[:][streamz_path,self._fillInOtherFields(streamz_path, {streamz_field_of_interest:True})] = series.Counter('1s', '+ 500x10000')
"""
""" # noqa
expected_formatted_code = """\
class Foo(object):
@ -236,7 +236,7 @@ def xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
def testB111764402(self):
unformatted_code = """\
x = self.stubs.stub(video_classification_map, 'read_video_classifications', (lambda external_ids, **unused_kwargs: {external_id: self._get_serving_classification('video') for external_id in external_ids}))
"""
""" # noqa
expected_formatted_code = """\
x = self.stubs.stub(video_classification_map, 'read_video_classifications',
(lambda external_ids, **unused_kwargs: {
@ -293,7 +293,7 @@ def potato(feeditems, browse_use_case=None):
if kumquat:
if not feeds_variants.variants['FEEDS_LOAD_PLAYLIST_VIDEOS_FOR_ALL_ITEMS'] and item.video:
continue
"""
""" # noqa
expected_formatted_code = """\
def potato(feeditems, browse_use_case=None):
for item in turnip:
@ -403,13 +403,13 @@ def _():
aaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccc(\
eeeeeeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffffffffffffffffffffff.\
ggggggggggggggggggggggggggggggggg.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh())
"""
""" # noqa
expected_formatted_code = """\
def _():
aaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccc(
eeeeeeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffffffffffffffffffffff
.ggggggggggggggggggggggggggggggggg.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh())
"""
""" # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -419,7 +419,7 @@ def f():
if (aaaaaaaaaaaaaa.bbbbbbbbbbbb.ccccc <= 0 and # pytype: disable=attribute-error
ddddddddddd.eeeeeeeee == constants.FFFFFFFFFFFFFF):
raise "yo"
"""
""" # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -493,7 +493,7 @@ INITIAL_SYMTAB = dict([(name, 'exception#' + name) for name in INITIAL_EXCEPTION
] * [(name, 'type#' + name) for name in INITIAL_TYPES] + [
(name, 'function#' + name) for name in INITIAL_FUNCTIONS
] + [(name, 'const#' + name) for name in INITIAL_CONSTS])
"""
""" # noqa
expected_formatted_code = """\
INITIAL_SYMTAB = dict(
[(name, 'exception#' + name) for name in INITIAL_EXCEPTIONS] *
@ -523,7 +523,7 @@ _MEMCACHE = lazy.MakeLazy(
lambda: function.call.mem.clients(FLAGS.some_flag_thingy, default_namespace=_LAZY_MEM_NAMESPACE, allow_pickle=True)
# pylint: enable=g-long-lambda
)
"""
""" # noqa
expected_formatted_code = """\
_MEMCACHE = lazy.MakeLazy(
# pylint: disable=g-long-lambda
@ -551,7 +551,7 @@ def _():
| m.Window(m.Delta('1h'))
| m.Join('successes', 'total')
| m.Point(m.VAL['successes'] / m.VAL['total']))))
"""
""" # noqa
expected_formatted_code = """\
def _():
success_rate_stream_table = module.Precompute(
@ -684,7 +684,7 @@ X = {
def testB67455376(self):
unformatted_code = """\
sponge_ids.extend(invocation.id() for invocation in self._client.GetInvocationsByLabels(labels))
"""
""" # noqa
expected_formatted_code = """\
sponge_ids.extend(invocation.id()
for invocation in self._client.GetInvocationsByLabels(labels))
@ -764,7 +764,7 @@ def _():
query = (
m.Fetch(n.Raw('monarch.BorgTask', '/proc/container/memory/usage'), { 'borg_user': borguser, 'borg_job': jobname })
| o.Window(m.Align('5m')) | p.GroupBy(['borg_user', 'borg_job', 'borg_cell'], q.Mean()))
"""
""" # noqa
expected_formatted_code = """\
def _():
query = (
@ -815,7 +815,7 @@ def _():
region=region,
forwardingRule=rule_name,
body={'fingerprint': base64.urlsafe_b64encode('invalid_fingerprint')}).execute()
"""
""" # noqa
expected_formatted_code = """\
def _():
with self.assertRaisesRegexp(errors.HttpError, 'Invalid'):
@ -843,7 +843,7 @@ def _():
def testB65241516(self):
unformatted_code = """\
checkpoint_files = gfile.Glob(os.path.join(TrainTraceDir(unit_key, "*", "*"), embedding_model.CHECKPOINT_FILENAME + "-*"))
"""
""" # noqa
expected_formatted_code = """\
checkpoint_files = gfile.Glob(
os.path.join(
@ -903,7 +903,7 @@ def _():
('/some/path/to/a/file/that/is/needed/by/this/process')
}
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
X = {
@ -912,7 +912,7 @@ def _():
('/some/path/to/a/file/that/is/needed/by/this/process')
}
}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -921,7 +921,7 @@ def _():
def _():
while ((not mpede_proc) or ((time_time() - last_modified) < FLAGS_boot_idle_timeout)):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
while ((not mpede_proc) or
@ -942,7 +942,7 @@ def _():
'read': 'name/some-type-of-very-long-name-for-reading-perms',
'modify': 'name/some-other-type-of-very-long-name-for-modifying'
})
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
labelacl = Env(
@ -954,14 +954,14 @@ def _():
'read': 'name/some-type-of-very-long-name-for-reading-perms',
'modify': 'name/some-other-type-of-very-long-name-for-modifying'
})
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
def testB34682902(self):
unformatted_code = textwrap.dedent("""\
logging.info("Mean angular velocity norm: %.3f", np.linalg.norm(np.mean(ang_vel_arr, axis=0)))
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
logging.info("Mean angular velocity norm: %.3f",
np.linalg.norm(np.mean(ang_vel_arr, axis=0)))
@ -1016,7 +1016,7 @@ def _():
'this is an entry',
}
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
environments = {
'prod': {
@ -1043,7 +1043,7 @@ def _():
'.....': 'this is an entry',
}
}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1125,7 +1125,7 @@ def _():
def __init__(self, metric, fields_cb=None):
self._fields_cb = fields_cb or (lambda *unused_args, **unused_kwargs: {})
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1154,7 +1154,7 @@ class _():
def xxxxx(self, yyyyy, zzzzzzzzzzzzzz=None): # A normal comment that runs over the column limit.
return 1
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class _():
@ -1166,7 +1166,7 @@ class _():
yyyyy,
zzzzzzzzzzzzzz=None): # A normal comment that runs over the column limit.
return 1
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1174,13 +1174,13 @@ class _():
unformatted_code = textwrap.dedent("""\
{'1234567890123456789012345678901234567890123456789012345678901234567890':
'1234567890123456789012345678901234567890'}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
{
'1234567890123456789012345678901234567890123456789012345678901234567890':
'1234567890123456789012345678901234567890'
}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1190,7 +1190,7 @@ class _():
def Function(self):
thing.Scrape('/aaaaaaaaa/bbbbbbbbbb/ccccc/dddd/eeeeeeeeeeeeee/ffffffffffffff').AndReturn(42)
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class Thing:
@ -1233,7 +1233,7 @@ class _():
def lulz():
return (some_long_module_name.SomeLongClassName.some_long_attribute_name
.some_long_method_name())
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1252,7 +1252,7 @@ class _():
'lllllllllllll': None, # use the default
}
}
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
xxxxxxxxxxxxxxxxxxx = {
@ -1280,7 +1280,7 @@ class _():
def _():
self.assertFalse(
evaluation_runner.get_larps_in_eval_set('these_arent_the_larps'))
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1291,7 +1291,7 @@ class _():
def __repr__(self):
return '<session %s on %s>' % (
self._id, self._stub._stub.rpc_channel().target()) # pylint:disable=protected-access
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1325,14 +1325,14 @@ class _():
def _():
_xxxxxxxxxxxxxxx(aaaaaaaa, bbbbbbbbbbbbbb.cccccccccc[
dddddddddddddddddddddddddddd.eeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffff])
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
_xxxxxxxxxxxxxxx(
aaaaaaaa,
bbbbbbbbbbbbbb.cccccccccc[dddddddddddddddddddddddddddd
.eeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffff])
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1381,7 +1381,7 @@ class _():
False:
self.bbb.cccccccccc(ddddddddddddddddddddddd.eeeeeeeeeeeeeeeeeeeeee)
})
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
if True:
if True:
@ -1391,7 +1391,7 @@ class _():
False:
self.bbb.cccccccccc(ddddddddddddddddddddddd.eeeeeeeeeeeeeeeeeeeeee)
})
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1399,7 +1399,7 @@ class _():
unformatted_code = textwrap.dedent("""\
def _():
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = (self.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccccccccccc)
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def _():
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = (
@ -1449,7 +1449,7 @@ class _():
code = textwrap.dedent("""\
def f():
ids = {u: i for u, i in zip(self.aaaaa, xrange(42, 42 + len(self.aaaaaa)))}
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(code)
self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@ -1488,7 +1488,7 @@ class _():
'materialize': lambda x: some_type_of_function('materialize ' + x.command_def),
'#': lambda x: x # do nothing
})
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
APPARENT_ACTIONS = (
'command_type',
@ -1498,7 +1498,7 @@ class _():
'#':
lambda x: x # do nothing
})
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1513,7 +1513,7 @@ class _():
"PPPPPPPPPPPPPPPPPPPPP":
FLAGS.aaaaaaaaaaaaaa + FLAGS.bbbbbbbbbbbbbbbbbbb,
})
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def foo():
if True:
@ -1525,7 +1525,7 @@ class _():
"PPPPPPPPPPPPPPPPPPPPP":
FLAGS.aaaaaaaaaaaaaa + FLAGS.bbbbbbbbbbbbbbbbbbb,
})
""")
""") # noqa
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@ -1593,7 +1593,7 @@ class _():
def foo():
if True:
return (struct.pack('aaaa', bbbbbbbbbb, ccccccccccccccc, dddddddd) + eeeeeee)
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
def foo():
if True:
@ -1608,7 +1608,7 @@ class _():
class A(object):
def xxxxxxxxx(self, aaaaaaa, bbbbbbb=ccccccccccc, dddddd=300, eeeeeeeeeeeeee=None, fffffffffffffff=0):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\
class A(object):
@ -1628,7 +1628,7 @@ class _():
class F():
def functioni(self, aaaaaaa, bbbbbbb, cccccc, dddddddddddddd, eeeeeeeeeeeeeee):
pass
""")
""") # noqa
expected_formatted_code = textwrap.dedent("""\