diff options
author | Bill Wendling <morbo@google.com> | 2021-11-04 04:52:22 -0700 |
---|---|---|
committer | Bill Wendling <morbo@google.com> | 2021-11-04 04:52:22 -0700 |
commit | 9d6808a3d9b9a0ea40efea0c7cc3247464dbc291 (patch) | |
tree | d482c284baa820eecde68dfeb44d0b1b57756fb9 | |
parent | 82ebfca90dba613c417b5bc7355db4ee2a5f4cb5 (diff) | |
download | yapf-9d6808a3d9b9a0ea40efea0c7cc3247464dbc291.tar.gz |
Add more files to flake8 run.
-rw-r--r-- | .flake8 | 6 | ||||
-rw-r--r-- | yapf/yapflib/py3compat.py | 8 | ||||
-rw-r--r-- | yapftests/blank_line_calculator_test.py | 2 | ||||
-rw-r--r-- | yapftests/file_resources_test.py | 2 | ||||
-rw-r--r-- | yapftests/line_joiner_test.py | 2 | ||||
-rw-r--r-- | yapftests/reformatter_basic_test.py | 147 | ||||
-rw-r--r-- | yapftests/reformatter_buganizer_test.py | 154 | ||||
-rw-r--r-- | yapftests/reformatter_facebook_test.py | 28 | ||||
-rw-r--r-- | yapftests/reformatter_pep8_test.py | 46 | ||||
-rw-r--r-- | yapftests/reformatter_python3_test.py | 12 | ||||
-rw-r--r-- | yapftests/reformatter_style_config_test.py | 2 | ||||
-rw-r--r-- | yapftests/yapf_test.py | 82 | ||||
-rw-r--r-- | yapftests/yapf_test_helper.py | 16 |
13 files changed, 253 insertions, 254 deletions
@@ -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 diff --git a/yapf/yapflib/py3compat.py b/yapf/yapflib/py3compat.py index 7c90523..8f15476 100644 --- a/yapf/yapflib/py3compat.py +++ b/yapf/yapflib/py3compat.py @@ -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'): diff --git a/yapftests/blank_line_calculator_test.py b/yapftests/blank_line_calculator_test.py index 193f419..80dc55c 100644 --- a/yapftests/blank_line_calculator_test.py +++ b/yapftests/blank_line_calculator_test.py @@ -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)) diff --git a/yapftests/file_resources_test.py b/yapftests/file_resources_test.py index 01efece..31184c4 100644 --- a/yapftests/file_resources_test.py +++ b/yapftests/file_resources_test.py @@ -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( diff --git a/yapftests/line_joiner_test.py b/yapftests/line_joiner_test.py index 6501bc8..67252a2 100644 --- a/yapftests/line_joiner_test.py +++ b/yapftests/line_joiner_test.py @@ -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) diff --git a/yapftests/reformatter_basic_test.py b/yapftests/reformatter_basic_test.py index 8b48c48..185d068 100644 --- a/yapftests/reformatter_basic_test.py +++ b/yapftests/reformatter_basic_test.py @@ -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( diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py index e95c96c..a324444 100644 --- a/yapftests/reformatter_buganizer_test.py +++ b/yapftests/reformatter_buganizer_test.py @@ -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("""\ class F(): @@ -1660,7 +1660,7 @@ class _(): | m.ggggggg(bbbbbbbbbbbbbbb)) | m.jjjj() | m.ppppp(m.vvv[0] + m.vvv[1])) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -1678,7 +1678,7 @@ class _(): | m.ggggggg(self.gggggggg)) | m.jjjj() | m.ppppp(m.VAL[0] / m.VAL[1])) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -1686,7 +1686,7 @@ class _(): unformatted_code = textwrap.dedent("""\ from a_very_long_or_indented_module_name_yada_yada import (long_argument_1, long_argument_2) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ from a_very_long_or_indented_module_name_yada_yada import ( long_argument_1, long_argument_2) @@ -1719,7 +1719,7 @@ class _(): and self.gggggg == other.gggggg and self.hhh == other.hhh and len(self.iiiiiiii) == len(other.iiiiiiii) and all(jjjjjjj in other.iiiiiiii for jjjjjjj in self.iiiiiiii)) - """) + """) # noqa try: style.SetGlobalStyle( @@ -1736,7 +1736,7 @@ class _(): def f(): if True: aaaaaa.bbbbbbbbbbbbbbbbbbbb[-1].cccccccccccccc.ddd().eeeeeeee(ffffffffffffff) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def f(): if True: @@ -1762,7 +1762,7 @@ class _(): 'xxx': '%s/cccccc/ddddddddddddddddddd.jar' % (eeeeee.FFFFFFFFFFFFFFFFFF), } - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -1785,7 +1785,7 @@ class _(): 'dddddddddddddddddddddddddddddddddddddddddd', } } - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -1834,7 +1834,7 @@ class _(): class_0_count=class_0_count, class_1_name=self.class_1_name, class_1_count=class_1_count)) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -1843,7 +1843,7 @@ class _(): if True: aaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbb( 'ccccccccccc', ddddddddd='eeeee').fffffffff([ggggggggggggggggggggg]) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -1907,7 +1907,7 @@ class _(): fffffffffff=(aaaaaaa.bbbbbbbb.ccccccc.dddddddddddddddddddd .Mmmmmmmmmmmmmmmmmm(-1, 'permission error'))): self.assertRaises(nnnnnnnnnnnnnnnn.ooooo, ppppp.qqqqqqqqqqqqqqqqq) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ class Foo(object): @@ -1918,7 +1918,7 @@ class _(): aaaaaaa.bbbbbbbb.ccccccc.dddddddddddddddddddd.Mmmmmmmmmmmmmmmmmm( -1, 'permission error'))): self.assertRaises(nnnnnnnnnnnnnnnn.ooooo, ppppp.qqqqqqqqqqqqqqqqq) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2054,7 +2054,7 @@ instance = ( os.path.join(aaaaa.bbbbb.ccccccccccc, DDDDDDDDDDDDDDD, "eeeeeeeee ffffffffff"), "rb") as gggggggggggggggggggg: print(gggggggggggggggggggg) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2092,7 +2092,7 @@ instance = ( eeeeeeeee=self.fffffffffffff )as gggg: pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: with aaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccc( @@ -2107,7 +2107,7 @@ instance = ( def foo(self): def bar(my_dict_name): self.my_dict_name['foo-bar-baz-biz-boo-baa-baa'].IncrementBy.assert_called_once_with('foo_bar_baz_boo') - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def foo(self): @@ -2115,7 +2115,7 @@ instance = ( self.my_dict_name[ 'foo-bar-baz-biz-boo-baa-baa'].IncrementBy.assert_called_once_with( 'foo_bar_baz_boo') - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2125,7 +2125,7 @@ instance = ( if 1: for row in AAAA: self.create(aaaaaaaa="/aaa/bbbb/cccc/dddddd/eeeeeeeeeeeeeeeeeeeeeeeeee/%s" % row [0].replace(".foo", ".bar"), aaaaa=bbb[1], ccccc=bbb[2], dddd=bbb[3], eeeeeeeeeee=[s.strip() for s in bbb[4].split(",")], ffffffff=[s.strip() for s in bbb[5].split(",")], gggggg=bbb[6]) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if 1: if 1: @@ -2139,7 +2139,7 @@ instance = ( eeeeeeeeeee=[s.strip() for s in bbb[4].split(",")], ffffffff=[s.strip() for s in bbb[5].split(",")], gggggg=bbb[6]) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2152,7 +2152,7 @@ instance = ( bad_slice = map(math.sqrt, an_array_with_an_exceedingly_long_name[:ARBITRARY_CONSTANT_A]) a_long_name_slicing = an_array_with_an_exceedingly_long_name[:ARBITRARY_CONSTANT_A] bad_slice = ("I am a crazy, no good, string what's too long, etc." + " no really ")[:ARBITRARY_CONSTANT_A] - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def main(unused_argv): ARBITRARY_CONSTANT_A = 10 @@ -2164,7 +2164,7 @@ instance = ( ARBITRARY_CONSTANT_A] bad_slice = ("I am a crazy, no good, string what's too long, etc." + " no really ")[:ARBITRARY_CONSTANT_A] - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2174,7 +2174,7 @@ if True: if True: if True: print(("Return code was %d" + (", and the process timed out." if did_time_out else ".")) % errorcode) -""" +""" # noqa expected_formatted_code = """\ if True: if True: @@ -2189,11 +2189,11 @@ if True: def testB15542157(self): unformatted_code = textwrap.dedent("""\ aaaaaaaaaaaa = bbbb.ccccccccccccccc(dddddd.eeeeeeeeeeeeee, ffffffffffffffffff, gggggg.hhhhhhhhhhhhhhhhh) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ aaaaaaaaaaaa = bbbb.ccccccccccccccc(dddddd.eeeeeeeeeeeeee, ffffffffffffffffff, gggggg.hhhhhhhhhhhhhhhhh) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2213,7 +2213,7 @@ if True: iiiiiiiiiiiiiiiiiii.jjjjjjjjjj.kkkkkkk, lllll.mm), nnnnnnnnnn=ooooooo.pppppppppp) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if aaaaaaa.bbbbbbbbbb: cccccc.dddddddddd(eeeeeeeeeee=fffffffffffff.gggggggggggggggggg) @@ -2228,7 +2228,7 @@ if True: dddddddddddd=eeeeeeeeeeeeeeeeeee.fffffffffffffffff( gggggg.hh, iiiiiiiiiiiiiiiiiii.jjjjjjjjjj.kkkkkkk, lllll.mm), nnnnnnnnnn=ooooooo.pppppppppp) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2256,7 +2256,7 @@ parameter_5, parameter_6): pass def foo1(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6): pass - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2264,11 +2264,11 @@ parameter_5, parameter_6): pass unformatted_code = textwrap.dedent("""\ self.aaaaaaaaaaa( # A comment in the middle of it all. 948.0/3600, self.bbb.ccccccccccccccccccccc(dddddddddddddddd.eeee, True)) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ self.aaaaaaaaaaa( # A comment in the middle of it all. 948.0 / 3600, self.bbb.ccccccccccccccccccccc(dddddddddddddddd.eeee, True)) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2283,7 +2283,7 @@ parameter_5, parameter_6): pass unformatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc().dddddddddddddddddddddddddd(1, 2, 3, 4) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc( ).dddddddddddddddddddddddddd(1, 2, 3, 4) @@ -2293,7 +2293,7 @@ parameter_5, parameter_6): pass unformatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc(x).dddddddddddddddddddddddddd(1, 2, 3, 4) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbb.ccccccccccccccccccccccccc( x).dddddddddddddddddddddddddd(1, 2, 3, 4) @@ -2303,11 +2303,11 @@ parameter_5, parameter_6): pass unformatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).dddddddddddddddddddddddddd(1, 2, 3, 4) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ aaaaaaaaaaaaaaaaaaaaaaaa( xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).dddddddddddddddddddddddddd(1, 2, 3, 4) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -2341,7 +2341,7 @@ dddddddddddddddddd().eeeeeeeeeeeeeeeeeeeee().fffffffffffffffff().ggggggggggggggg expected_formatted_code = textwrap.dedent("""\ shelf_renderer.expand_text = text.translate_to_unicode(expand_text % {'creator': creator}) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) diff --git a/yapftests/reformatter_facebook_test.py b/yapftests/reformatter_facebook_test.py index 289aa85..2e6b1d7 100644 --- a/yapftests/reformatter_facebook_test.py +++ b/yapftests/reformatter_facebook_test.py @@ -53,7 +53,7 @@ class TestsForFacebookStyle(yapf_test_helper.YAPFTest): first_argument_on_the_same_line, second_argument_makes_the_line_too_long ): pass - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -151,7 +151,7 @@ v, w, x, y, z pass except (IOError, OSError, LookupError, RuntimeError, OverflowError) as exception: pass - """) + """) # noqa pass1_code = textwrap.dedent("""\ try: pass @@ -201,7 +201,7 @@ v, w, x, y, z unformatted_code = textwrap.dedent("""\ if True: self.assertEqual(result.reason_not_added, "current preflight is still running") - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: self.assertEqual( @@ -220,7 +220,7 @@ v, w, x, y, z if clues_lists: return cls.single_constraint_not(clues_lists, effect, constraints[0], constraint_manager) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ class Foo: class Bar: @@ -230,7 +230,7 @@ v, w, x, y, z return cls.single_constraint_not( clues_lists, effect, constraints[0], constraint_manager ) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -241,7 +241,7 @@ v, w, x, y, z cls.effect_clues = { 'effect': Clue((cls.effect_time, 'apache_host'), effect_line, 40) } - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -283,7 +283,7 @@ v, w, x, y, z ('localhost', os.path.join(path, 'node_1.log'), super_parser), ('localhost', os.path.join(path, 'node_2.log'), super_parser) ] - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ class Foo(): def _pack_results_for_constraint_or(): @@ -319,7 +319,7 @@ v, w, x, y, z ('localhost', os.path.join(path, 'node_1.log'), super_parser), ('localhost', os.path.join(path, 'node_2.log'), super_parser) ] - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -331,7 +331,7 @@ v, w, x, y, z effect_line_offset, line_content, LineSource('localhost', xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) ) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) self.assertCodeEqual(code, reformatter.Reformat(uwlines)) @@ -374,7 +374,7 @@ v, w, x, y, z (clue for clue in combination if not clue == Verifier.UNMATCHED), constraints, InvestigationResult.OR ) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(code) reformatted_code = reformatter.Reformat(uwlines) self.assertCodeEqual(code, reformatted_code) @@ -388,8 +388,8 @@ v, w, x, y, z def foo(): if 0: return False - - + + #a deadly comment elif 1: return True @@ -401,7 +401,7 @@ v, w, x, y, z def foo(): if 0: return False - + #a deadly comment elif 1: return True @@ -416,7 +416,7 @@ v, w, x, y, z unformatted_code = """\ if (isinstance(value , (StopIteration , StopAsyncIteration )) and exc.__cause__ is value_asdfasdfasdfasdfsafsafsafdasfasdfs): return False -""" +""" # noqa expected_formatted_code = """\ if ( isinstance(value, (StopIteration, StopAsyncIteration)) and diff --git a/yapftests/reformatter_pep8_test.py b/yapftests/reformatter_pep8_test.py index c70ec49..b07ae1e 100644 --- a/yapftests/reformatter_pep8_test.py +++ b/yapftests/reformatter_pep8_test.py @@ -132,7 +132,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): zzzzz = '%s-%s'.ww(xxxxxxxxxxxxxxxxxxxxxxxxxx + 1, xxxxxxxxxxxxxxxxx.yyy + 1) zzzzz = '%s-%s' % (xxxxxxxxxxxxxxxxxxxxxxx + 1, xxxxxxxxxxxxxxxxxxxxx + 1) zzzzz = '%s-%s'.ww(xxxxxxxxxxxxxxxxxxxxxxx + 1, xxxxxxxxxxxxxxxxxxxxx + 1) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def f(): if True: @@ -172,7 +172,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): xxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb' ): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def f(): @@ -181,7 +181,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): and xxxxxxxxxxxxxxxxxxxx( yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'): pass - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -189,7 +189,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): unformatted_code = textwrap.dedent("""\ if True: runtime_mins = (program_end_time - program_start_time).total_seconds() / 60.0 - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: runtime_mins = (program_end_time - @@ -212,7 +212,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): for connection in itertools.chain(branch.contact, branch.address, morestuff.andmore.andmore.andmore.andmore.andmore.andmore.andmore): dosomething(connection) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if (aaaaaaaaaaaaaa + bbbbbbbbbbbbbbbb == ccccccccccccccccc and xxxxxxxxxxxxx or yyyyyyyyyyyyyyyyy): @@ -233,7 +233,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): branch.contact, branch.address, morestuff.andmore.andmore.andmore.andmore.andmore.andmore.andmore): dosomething(connection) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -250,7 +250,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): update.message.supergroup_chat_created or update.message.channel_chat_created or update.message.migrate_to_chat_id or update.message.migrate_from_chat_id or update.message.pinned_message) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def foo(): return bool( @@ -263,7 +263,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): or update.message.migrate_to_chat_id or update.message.migrate_from_chat_id or update.message.pinned_message) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -275,13 +275,13 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): if True: if True: keys.append(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) # may be unassigned. - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: if True: keys.append( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) # may be unassigned. - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -293,7 +293,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): unformatted_code = textwrap.dedent("""\ a_very_long_function_name(long_argument_name_1=1, long_argument_name_2=2, long_argument_name_3=3, long_argument_name_4=4) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ a_very_long_function_name( long_argument_name_1=1, @@ -311,7 +311,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): unformatted_code = textwrap.dedent("""\ def foo(): df = df[(df['campaign_status'] == 'LIVE') & (df['action_status'] == 'LIVE')] - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def foo(): df = df[(df['campaign_status'] == 'LIVE') @@ -390,7 +390,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): 'description': _("Lorem ipsum dolor met sit amet elit, si vis pacem para bellum " "elites nihi very long string."), } - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ some_dict = { 'title': _("I am example data"), @@ -399,21 +399,21 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): "elites nihi very long string." ), } - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) unformatted_code = textwrap.dedent("""\ X = {'a': 1, 'b': 2, 'key': this_is_a_function_call_that_goes_over_the_column_limit_im_pretty_sure()} - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ X = { 'a': 1, 'b': 2, 'key': this_is_a_function_call_that_goes_over_the_column_limit_im_pretty_sure() } - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -423,7 +423,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): 'category': category, 'role': forms.ModelChoiceField(label=_("Role"), required=False, queryset=category_roles, initial=selected_role, empty_label=_("No access"),), } - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ attrs = { 'category': category, @@ -446,7 +446,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): required=False, help_text=_("Optional CSS class used to customize this category appearance from templates."), ) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ css_class = forms.CharField( label=_("CSS class"), @@ -455,7 +455,7 @@ class TestsForPEP8Style(yapf_test_helper.YAPFTest): "Optional CSS class used to customize this category appearance from templates." ), ) - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -528,7 +528,7 @@ class Demo: unformatted_code = """\ def _(): raise ValueError('This is a long message that ends with an argument: ' + str(42)) -""" +""" # noqa expected_formatted_code = """\ def _(): raise ValueError('This is a long message that ends with an argument: ' @@ -604,7 +604,7 @@ class _(): justify: str = 'rjust'): self._cs = charset self._preprocess = preprocess - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ class _(): @@ -654,7 +654,7 @@ class _(): unformatted_code = textwrap.dedent("""\ _ = (klsdfjdklsfjksdlfjdklsfjdslkfjsdkl is not ksldfjsdklfjdklsfjdklsfjdklsfjdsklfjdklsfj) _ = (klsdfjdklsfjksdlfjdklsfjdslkfjsdkl not in {ksldfjsdklfjdklsfjdklsfjdklsfjdsklfjdklsfj}) - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ _ = (klsdfjdklsfjksdlfjdklsfjdslkfjsdkl is not ksldfjsdklfjdklsfjdklsfjdklsfjdsklfjdklsfj) @@ -687,7 +687,7 @@ class _(): 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( diff --git a/yapftests/reformatter_python3_test.py b/yapftests/reformatter_python3_test.py index ae55755..dbf3930 100644 --- a/yapftests/reformatter_python3_test.py +++ b/yapftests/reformatter_python3_test.py @@ -36,7 +36,7 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest): unformatted_code = textwrap.dedent("""\ def x(aaaaaaaaaaaaaaa:int,bbbbbbbbbbbbbbbb:str,ccccccccccccccc:dict,eeeeeeeeeeeeee:set={1, 2, 3})->bool: pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def x(aaaaaaaaaaaaaaa: int, bbbbbbbbbbbbbbbb: str, @@ -51,12 +51,12 @@ class TestsForPython3Code(yapf_test_helper.YAPFTest): unformatted_code = textwrap.dedent("""\ def func(arg=long_function_call_that_pushes_the_line_over_eighty_characters()) -> ReturnType: pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def func(arg=long_function_call_that_pushes_the_line_over_eighty_characters() ) -> ReturnType: pass - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code) self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines)) @@ -253,7 +253,7 @@ None.__ne__() self, *args: Optional[automation_converter.PyiCollectionAbc]) -> List[ automation_converter.PyiCollectionAbc]: pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def _ReduceAbstractContainers( self, *args: Optional[automation_converter.PyiCollectionAbc] @@ -297,7 +297,7 @@ def open_file(file, mode='r', buffering=-1, encoding=None, errors=None, newline= def run_sync_in_worker_thread(sync_fn, *args, cancellable=False, limiter=None): pass -""" +""" # noqa expected_formatted_code = """\ async def open_file( file, @@ -454,7 +454,7 @@ def rrrrrrrrrrrrrrrrrrrrrr( def raw_message( # pylint: disable=too-many-arguments self, text, user_id=1000, chat_type='private', forward_date=None, forward_from=None): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def raw_message( # pylint: disable=too-many-arguments self, diff --git a/yapftests/reformatter_style_config_test.py b/yapftests/reformatter_style_config_test.py index d77c197..9c258ca 100644 --- a/yapftests/reformatter_style_config_test.py +++ b/yapftests/reformatter_style_config_test.py @@ -155,7 +155,7 @@ class TestsForStyleConfig(yapf_test_helper.YAPFTest): plt.plot(veryverylongvariablename, veryverylongvariablename, marker="x", color="r") - """) + """) # noqa uwlines = yapf_test_helper.ParseAndUnwrap(formatted_code) self.assertCodeEqual(formatted_code, reformatter.Reformat(uwlines)) finally: diff --git a/yapftests/yapf_test.py b/yapftests/yapf_test.py index 4e062cf..e116043 100644 --- a/yapftests/yapf_test.py +++ b/yapftests/yapf_test.py @@ -202,7 +202,7 @@ class FormatFileTest(unittest.TestCase): # yapf: disable a(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccccccc, ddddddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeeee) # yapf: enable - """) + """) # noqa with utils.TempFileContents(self.test_tmpdir, code) as filepath: formatted_code, _, _ = yapf_api.FormatFile(filepath, style_config='pep8') self.assertCodeEqual(code, formatted_code) @@ -540,7 +540,7 @@ class CommandLineTest(unittest.TestCase): expected_formatted_code = textwrap.dedent("""\ a_very_long_statement_that_extends_way_beyond # Comment short # This is a shorter statement - """) + """) # noqa style_file = textwrap.dedent(u'''\ [style] spaces_before_comment = 15, 20 @@ -576,7 +576,7 @@ class CommandLineTest(unittest.TestCase): subprocess.check_call(YAPF_BINARY + ['--diff', filepath], stdout=out) except subprocess.CalledProcessError as e: # Indicates the text changed. - self.assertEqual(e.returncode, 1) # pylint: disable=g-assert-in-except + self.assertEqual(e.returncode, 1) # pylint: disable=g-assert-in-except # noqa def testReformattingSpecificLines(self): unformatted_code = textwrap.dedent("""\ @@ -588,7 +588,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -599,7 +599,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass - """) + """) # noqa # TODO(ambv): the `expected_formatted_code` here is not PEP8 compliant, # raising "E129 visually indented line with same indent as next logical # line" with flake8. @@ -639,7 +639,7 @@ class CommandLineTest(unittest.TestCase): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass # yapf: enable - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -652,7 +652,7 @@ class CommandLineTest(unittest.TestCase): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass # yapf: enable - """) + """) # noqa self.assertYapfReformats(unformatted_code, expected_formatted_code) def testReformattingSkippingToEndOfFile(self): @@ -672,7 +672,7 @@ class CommandLineTest(unittest.TestCase): xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -691,7 +691,7 @@ class CommandLineTest(unittest.TestCase): xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'): pass - """) + """) # noqa self.assertYapfReformats(unformatted_code, expected_formatted_code) def testReformattingSkippingSingleLine(self): @@ -703,7 +703,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): # yapf: disable pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -714,7 +714,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): # yapf: disable pass - """) + """) # noqa self.assertYapfReformats(unformatted_code, expected_formatted_code) def testDisableWholeDataStructure(self): @@ -758,7 +758,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy (zzzzzzzzzzzzz [0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): # yapf: disable pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -769,7 +769,7 @@ class CommandLineTest(unittest.TestCase): def g(): if (xxxxxxxxxxxx.yyyyyyyy (zzzzzzzzzzzzz [0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): # yapf: disable pass - """) + """) # noqa self.assertYapfReformats(unformatted_code, expected_formatted_code) def testRetainingVerticalWhitespace(self): @@ -784,7 +784,7 @@ class CommandLineTest(unittest.TestCase): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ def h(): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and @@ -797,7 +797,7 @@ class CommandLineTest(unittest.TestCase): if (xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0]) == 'aaaaaaaaaaa' and xxxxxxxxxxxx.yyyyyyyy(zzzzzzzzzzzzz[0].mmmmmmmm[0]) == 'bbbbbbb'): pass - """) + """) # noqa self.assertYapfReformats( unformatted_code, expected_formatted_code, @@ -902,7 +902,7 @@ x = { <b>Residence: </b>"""+palace["Winter"]+"""<br> </body> </html>""" - ''') + ''') # noqa expected_formatted_code = textwrap.dedent('''\ foo = 42 def f(): @@ -912,7 +912,7 @@ x = { <b>Residence: </b>"""+palace["Winter"]+"""<br> </body> </html>""" - ''') + ''') # noqa self.assertYapfReformats( unformatted_code, expected_formatted_code, @@ -1008,7 +1008,7 @@ x = { 'eeeeeeeeeeeeeeeeeeeeeeeee.%s' % c.ffffffffffff), gggggggggggg.hhhhhhhhh(c, c.ffffffffffff)) iiiii = jjjjjjjjjjjjjj.iiiii - """) + """) # noqa self.assertYapfReformats( unformatted_code, expected_formatted_code, @@ -1058,7 +1058,7 @@ x = { 'eeeeeeeeeeeeeeeeeeeeeeeee.%s' % c.ffffffffffff), gggggggggggg.hhhhhhhhh(c, c.ffffffffffff)) iiiii = jjjjjjjjjjjjjj.iiiii - """) + """) # noqa self.assertYapfReformats( unformatted_code, expected_formatted_code, @@ -1128,7 +1128,7 @@ x = { first_argument_on_the_same_line, second_argument_makes_the_line_too_long ): pass - """) + """) # noqa self.assertYapfReformats( unformatted_code, expected_formatted_fb_code, @@ -1247,7 +1247,7 @@ def foo_function(): def foo_function(): if True: pass -""" +""" # noqa: W191,E101 style_contents = u"""\ [style] based_on_style = yapf @@ -1271,7 +1271,7 @@ def f(): 'hello', 'world', ] -""" +""" # noqa: W191,E101 style_contents = u"""\ [style] based_on_style = yapf @@ -1296,7 +1296,7 @@ def foo_function( 'hello', 'world', ] -""" +""" # noqa: W191,E101 style_contents = u"""\ [style] based_on_style = yapf @@ -1324,7 +1324,7 @@ def foo_function(arg1, arg2, 'hello', 'world', ] -""" +""" # noqa: W191,E101 style_contents = u"""\ [style] based_on_style = yapf @@ -1622,11 +1622,11 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): """) expected_formatted_code = textwrap.dedent("""\ foo = '1' # Aligned at first list value - + foo = '2__<15>' # Aligned at second list value - + foo = '3____________<25>' # Aligned at third list value - + foo = '4______________________<35>' # Aligned beyond list values """) self._Check(unformatted_code, expected_formatted_code) @@ -1705,7 +1705,7 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): # Line 6 # Aligned with prev comment block - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ func(1) # Line 1 func(2) # Line 2 @@ -1715,7 +1715,7 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): # Line 6 # Aligned with prev comment block - """) + """) # noqa self._Check(unformatted_code, expected_formatted_code) def testBlockIndentedFuncSuffix(self): @@ -1732,14 +1732,14 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): def Func(): pass - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: func(1) # Line 1 func(2) # Line 2 # Line 3 func(3) # Line 4 - + # Line 5 - SpliceComments makes this a new block # Line 6 @@ -1760,7 +1760,7 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): func(3) # Line 4 # Line 5 # Line 6 - + # Not aligned """) expected_formatted_code = textwrap.dedent("""\ @@ -1787,9 +1787,9 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): func(3) # Line 4 # Line 5 # Line 6 - + # Not aligned - """) + """) # noqa expected_formatted_code = textwrap.dedent("""\ if True: if True: @@ -1800,7 +1800,7 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest): func(3) # Line 4 # Line 5 # Line 6 - + # Not aligned """) self._Check(unformatted_code, expected_formatted_code) @@ -1923,7 +1923,7 @@ class SpacesAroundDictTest(_SpacesAroundDictListTupleTestImpl): { 1: 2 } { k: v for k, v in other.items() } { k for k in [1, 2, 3] } - + # The following statements should not change {} {1 : 2} # yapf: disable @@ -1931,7 +1931,7 @@ class SpacesAroundDictTest(_SpacesAroundDictListTupleTestImpl): # yapf: disable {1 : 2} # yapf: enable - + # Dict settings should not impact lists or tuples [1, 2] (3, 4) @@ -1982,12 +1982,12 @@ class SpacesAroundListTest(_SpacesAroundDictListTupleTestImpl): index[a, b] [] [v for v in [1,2,3] if v & 1] # yapf: disable - + # yapf: disable [a,b,c] [4,5,] # yapf: enable - + # List settings should not impact dicts or tuples {a: b} (1, 2) @@ -2040,14 +2040,14 @@ class SpacesAroundTupleTest(_SpacesAroundDictListTupleTestImpl): (this_func or that_func)(3, 4) if (True and False): pass () - + (0, 1) # yapf: disable # yapf: disable (0, 1) (2, 3) # yapf: enable - + # Tuple settings should not impact dicts or lists {a: b} [3, 4] diff --git a/yapftests/yapf_test_helper.py b/yapftests/yapf_test_helper.py index f6a2b66..df89b70 100644 --- a/yapftests/yapf_test_helper.py +++ b/yapftests/yapf_test_helper.py @@ -41,17 +41,17 @@ class YAPFTest(unittest.TestCase): if code != expected_code: msg = ['Code format mismatch:', 'Expected:'] linelen = style.Get('COLUMN_LIMIT') - for l in expected_code.splitlines(): - if len(l) > linelen: - msg.append('!> %s' % l) + for line in expected_code.splitlines(): + if len(line) > linelen: + msg.append('!> %s' % line) else: - msg.append(' > %s' % l) + msg.append(' > %s' % line) msg.append('Actual:') - for l in code.splitlines(): - if len(l) > linelen: - msg.append('!> %s' % l) + for line in code.splitlines(): + if len(line) > linelen: + msg.append('!> %s' % line) else: - msg.append(' > %s' % l) + msg.append(' > %s' % line) msg.append('Diff:') msg.extend( difflib.unified_diff( |