diff -Nru autopep8-1.5.7/autopep8.egg-info/PKG-INFO autopep8-1.6.0/autopep8.egg-info/PKG-INFO --- autopep8-1.5.7/autopep8.egg-info/PKG-INFO 2021-04-30 06:04:38.000000000 +0000 +++ autopep8-1.6.0/autopep8.egg-info/PKG-INFO 2021-10-24 06:47:29.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.5.7 +Version: 1.6.0 Summary: A tool that automatically formats Python code to conform to the PEP 8 style guide Home-page: https://github.com/hhatto/autopep8 Author: Hideo Hattori @@ -449,5 +449,6 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance diff -Nru autopep8-1.5.7/autopep8.egg-info/requires.txt autopep8-1.6.0/autopep8.egg-info/requires.txt --- autopep8-1.5.7/autopep8.egg-info/requires.txt 2021-04-30 06:04:38.000000000 +0000 +++ autopep8-1.6.0/autopep8.egg-info/requires.txt 2021-10-24 06:47:29.000000000 +0000 @@ -1,2 +1,2 @@ -pycodestyle>=2.7.0 +pycodestyle>=2.8.0 toml diff -Nru autopep8-1.5.7/autopep8.py autopep8-1.6.0/autopep8.py --- autopep8-1.5.7/autopep8.py 2021-04-30 06:04:15.000000000 +0000 +++ autopep8-1.6.0/autopep8.py 2021-10-24 06:29:35.000000000 +0000 @@ -100,7 +100,7 @@ unicode = str -__version__ = '1.5.7' +__version__ = '1.6.0' CR = '\r' @@ -531,6 +531,7 @@ options and (options.aggressive >= 2 or options.experimental) else self.fix_long_line_physically) self.fix_e703 = self.fix_e702 + self.fix_w292 = self.fix_w291 self.fix_w293 = self.fix_w291 def _fix_source(self, results): @@ -720,6 +721,11 @@ spaces_to_add = num_indent_spaces - len(_get_indentation(target)) + indent_length = len(_get_indentation(target)) + spaces_to_add = num_indent_spaces - indent_length + if num_indent_spaces == 0 and indent_length == 0: + spaces_to_add = 4 + if spaces_to_add >= 0: self.source[line_index] = (' ' * spaces_to_add + self.source[line_index]) @@ -1737,9 +1743,15 @@ Skip if ignore string is produced in the refactored code. """ + not_found_end_of_file_newline = source and source.rstrip("\r\n") == source + if not_found_end_of_file_newline: + input_source = source + "\n" + else: + input_source = source + from lib2to3 import pgen2 try: - new_text = refactor_with_2to3(source, + new_text = refactor_with_2to3(input_source, fixer_names=fixer_names, filename=filename) except (pgen2.parse.ParseError, @@ -1752,6 +1764,9 @@ if ignore in new_text and ignore not in source: return source + if not_found_end_of_file_newline: + return new_text.rstrip("\r\n") + return new_text @@ -2990,9 +3005,11 @@ return checker.report.full_error_results() -def _remove_leading_and_normalize(line): +def _remove_leading_and_normalize(line, with_rstrip=True): # ignore FF in first lstrip() - return line.lstrip(' \t\v').rstrip(CR + LF) + '\n' + if with_rstrip: + return line.lstrip(' \t\v').rstrip(CR + LF) + '\n' + return line.lstrip(' \t\v') class Reindenter(object): @@ -3019,8 +3036,11 @@ self.lines.append(line) else: # Only expand leading tabs. - self.lines.append(_get_indentation(line).expandtabs() + - _remove_leading_and_normalize(line)) + with_rstrip = line_number != len(source_lines) + self.lines.append( + _get_indentation(line).expandtabs() + + _remove_leading_and_normalize(line, with_rstrip) + ) self.lines.insert(0, None) self.index = 1 # index into self.lines of next line @@ -3257,10 +3277,10 @@ disabled_start = None for line, commanded_enabled in sorted(enable_commands.items()): - if currently_enabled is True and commanded_enabled is False: + if commanded_enabled is False and currently_enabled is True: disabled_start = line currently_enabled = False - elif currently_enabled is False and commanded_enabled is True: + elif commanded_enabled is True and currently_enabled is False: disabled_ranges.append((disabled_start, line)) currently_enabled = True @@ -3270,6 +3290,17 @@ return disabled_ranges +def filter_disabled_results(result, disabled_ranges): + """Filter out reports based on tuple of disabled ranges. + + """ + line = result['line'] + for disabled_range in disabled_ranges: + if disabled_range[0] <= line <= disabled_range[1]: + return False + return True + + def filter_results(source, results, aggressive): """Filter out spurious reports from pycodestyle. @@ -3285,11 +3316,13 @@ # Filter out the disabled ranges disabled_ranges = get_disabled_ranges(source) - if len(disabled_ranges) > 0: - results = [result for result in results - if any(result['line'] not in range(*disabled_range) - for disabled_range in disabled_ranges) - ] + if disabled_ranges: + results = [ + result for result in results if filter_disabled_results( + result, + disabled_ranges, + ) + ] has_e901 = any(result['id'].lower() == 'e901' for result in results) @@ -3448,9 +3481,11 @@ """Return fixed line endings. All lines will be modified to use the most common line ending. - """ - return [line.rstrip('\n\r') + newline for line in lines] + line = [line.rstrip('\n\r') + newline for line in lines] + if line and lines[-1] == lines[-1].rstrip('\n\r'): + line[-1] = line[-1].rstrip('\n\r') + return line def mutual_startswith(a, b): diff -Nru autopep8-1.5.7/debian/changelog autopep8-1.6.0/debian/changelog --- autopep8-1.5.7/debian/changelog 2021-08-21 18:12:36.000000000 +0000 +++ autopep8-1.6.0/debian/changelog 2021-11-07 11:15:44.000000000 +0000 @@ -1,3 +1,10 @@ +autopep8 (1.6.0-1) unstable; urgency=medium + + * New upstream release + * Fix 'pypi-homepage' + + -- Sylvestre Ledru Sun, 07 Nov 2021 12:15:44 +0100 + autopep8 (1.5.7-1) unstable; urgency=medium * Upload to unstable diff -Nru autopep8-1.5.7/debian/control autopep8-1.6.0/debian/control --- autopep8-1.5.7/debian/control 2021-08-21 18:11:57.000000000 +0000 +++ autopep8-1.6.0/debian/control 2021-11-07 11:15:44.000000000 +0000 @@ -7,7 +7,7 @@ debhelper-compat (= 12), pycodestyle, python3-pycodestyle (>= 2.3.1), dh-python, help2man, python3-toml Standards-Version: 4.2.1 -Homepage: https://pypi.python.org/pypi/autopep8/ +Homepage: https://github.com/hhatto/autopep8 Vcs-Git: https://salsa.debian.org/python-team/packages/autopep8.git Vcs-Browser: https://salsa.debian.org/python-team/packages/autopep8 diff -Nru autopep8-1.5.7/debian/copyright autopep8-1.6.0/debian/copyright --- autopep8-1.5.7/debian/copyright 2020-04-11 11:02:36.000000000 +0000 +++ autopep8-1.6.0/debian/copyright 2021-11-07 11:15:44.000000000 +0000 @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: autopep8 -Source: https://pypi.python.org/pypi/autopep8 +Source: https://github.com/hhatto/autopep8 Files: * Copyright: 2010-2011 Hideo Hattori diff -Nru autopep8-1.5.7/debian/patches/lower-pycodestyle.diff autopep8-1.6.0/debian/patches/lower-pycodestyle.diff --- autopep8-1.5.7/debian/patches/lower-pycodestyle.diff 2021-08-21 18:11:57.000000000 +0000 +++ autopep8-1.6.0/debian/patches/lower-pycodestyle.diff 2021-11-07 11:15:44.000000000 +0000 @@ -6,7 +6,7 @@ INSTALL_REQUIRES = ( -- ['pycodestyle >= 2.7.0', 'toml'] +- ['pycodestyle >= 2.8.0', 'toml'] + ['pycodestyle >= 2.6.0', 'toml'] ) diff -Nru autopep8-1.5.7/PKG-INFO autopep8-1.6.0/PKG-INFO --- autopep8-1.5.7/PKG-INFO 2021-04-30 06:04:38.000000000 +0000 +++ autopep8-1.6.0/PKG-INFO 2021-10-24 06:47:29.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.5.7 +Version: 1.6.0 Summary: A tool that automatically formats Python code to conform to the PEP 8 style guide Home-page: https://github.com/hhatto/autopep8 Author: Hideo Hattori @@ -449,5 +449,6 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance diff -Nru autopep8-1.5.7/setup.py autopep8-1.6.0/setup.py --- autopep8-1.5.7/setup.py 2021-03-22 08:27:11.000000000 +0000 +++ autopep8-1.6.0/setup.py 2021-10-24 06:24:34.000000000 +0000 @@ -10,7 +10,7 @@ INSTALL_REQUIRES = ( - ['pycodestyle >= 2.7.0', 'toml'] + ['pycodestyle >= 2.8.0', 'toml'] ) @@ -47,6 +47,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Software Development :: Quality Assurance', ], diff -Nru autopep8-1.5.7/test/test_autopep8.py autopep8-1.6.0/test/test_autopep8.py --- autopep8-1.5.7/test/test_autopep8.py 2021-03-31 14:50:32.000000000 +0000 +++ autopep8-1.6.0/test/test_autopep8.py 2021-10-24 06:24:34.000000000 +0000 @@ -1765,6 +1765,20 @@ with autopep8_context(line, options=['--hang-closing']) as result: self.assertEqual(fixed, result) + def test_e133_no_indentation_line(self): + line = """\ +e = [ + 1, 2 +] +""" + fixed = """\ +e = [ + 1, 2 + ] +""" + with autopep8_context(line, options=['--hang-closing']) as result: + self.assertEqual(fixed, result) + def test_e133_not_effected(self): line = """\ if True: @@ -3829,6 +3843,20 @@ with autopep8_context(line) as result: self.assertEqual(fixed, result) + @unittest.skipIf( + (sys.version_info.major >= 3 and sys.version_info.minor < 8) + or sys.version_info.major < 3, + "syntax error in Python3.7 and lower version", + ) + def test_e501_with_pep572_assignment_expressions(self): + line = """\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1 +if bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb := aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: + print(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) +""" + with autopep8_context(line, options=['-aa']) as result: + self.assertEqual(line, result) + def test_e502(self): line = "print('abc'\\\n 'def')\n" fixed = "print('abc'\n 'def')\n" @@ -4419,6 +4447,12 @@ '--select=W292']) as result: self.assertEqual(fixed, result) + def test_w292_ignore(self): + line = "1\n2" + with autopep8_context(line, options=['--aggressive', + '--ignore=W292']) as result: + self.assertEqual(line, result) + def test_w293(self): line = '1\n \n2\n' fixed = '1\n\n2\n' @@ -5201,6 +5235,32 @@ with autopep8_context(test_code) as result: self.assertEqual(expected_output, result) + def test_autopep8_disable_multi(self): + test_code = """\ +fix=1 +# autopep8: off +skip=1 +# autopep8: on +fix=2 +# autopep8: off +skip=2 +# autopep8: on +fix=3 +""" + expected_output = """\ +fix = 1 +# autopep8: off +skip=1 +# autopep8: on +fix = 2 +# autopep8: off +skip=2 +# autopep8: on +fix = 3 +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + def test_fmt_disable(self): test_code = """\ # fmt: off @@ -5275,6 +5335,92 @@ with autopep8_context(test_code) as result: self.assertEqual(expected_output, result) + def test_fmt_multi_disable_and_reenable(self): + test_code = """\ +fix=1 +# fmt: off +skip=1 +# fmt: on +fix=2 +# fmt: off +skip=2 +# fmt: on +fix=3 +""" + expected_output = """\ +fix = 1 +# fmt: off +skip=1 +# fmt: on +fix = 2 +# fmt: off +skip=2 +# fmt: on +fix = 3 +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_multi_disable_complex(self): + test_code = """\ +fix=1 +# fmt: off +skip=1 +# fmt: off +fix=2 +# fmt: off +skip=2 +# fmt: on +fix=3 +""" + expected_output = """\ +fix = 1 +# fmt: off +skip=1 +# fmt: off +fix=2 +# fmt: off +skip=2 +# fmt: on +fix = 3 +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_multi_disable_complex_multi(self): + test_code = """\ +fix=1 +# fmt: off +skip=1 +# fmt: off +fix=2 +# fmt: on +fix=22 +# fmt: on +fix=222 +# fmt: off +skip=2 +# fmt: on +fix=3 +""" + expected_output = """\ +fix = 1 +# fmt: off +skip=1 +# fmt: off +fix=2 +# fmt: on +fix = 22 +# fmt: on +fix = 222 +# fmt: off +skip=2 +# fmt: on +fix = 3 +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + def test_general_disable(self): test_code = """\ # fmt: off @@ -5503,7 +5649,6 @@ def test_exit_code_with_io_error(self): line = "import sys\ndef a():\n print(1)\n" with readonly_temporary_file_context(line) as filename: - print(filename) p = Popen(list(AUTOPEP8_CMD_TUPLE) + ['--in-place', filename], stdout=PIPE, stderr=PIPE) p.communicate() @@ -5662,6 +5807,7 @@ ['--jobs=3', '--diff'], stdout=PIPE) p.wait() output = p.stdout.read().decode() + p.stdout.close() actual_diffs = [] for filename in files: @@ -6045,7 +6191,8 @@ target_filename = os.path.join(dirname, "foo.py") with open(target_filename, "w") as fp: fp.write(line) - p = Popen(list(AUTOPEP8_CMD_TUPLE) + [target_filename], stdout=PIPE) + p = Popen(list(AUTOPEP8_CMD_TUPLE) + + [target_filename], stdout=PIPE) self.assertEqual(p.communicate()[0].decode("utf-8"), line) self.assertEqual(p.returncode, autopep8.EXIT_CODE_OK) @@ -6060,7 +6207,8 @@ target_filename = os.path.join(dirname, "foo.py") with open(target_filename, "w") as fp: fp.write(line) - p = Popen(list(AUTOPEP8_CMD_TUPLE) + [target_filename, "-vvv"], stdout=PIPE) + p = Popen(list(AUTOPEP8_CMD_TUPLE) + + [target_filename, "-vvv"], stdout=PIPE) output = p.communicate()[0].decode("utf-8") self.assertTrue(line in output) self.assertTrue(verbose_line in output) @@ -6075,7 +6223,8 @@ target_filename = os.path.join(dirname, "foo.py") with open(target_filename, "w") as fp: fp.write(line) - p = Popen(list(AUTOPEP8_CMD_TUPLE) + [target_filename, ], stdout=PIPE) + p = Popen(list(AUTOPEP8_CMD_TUPLE) + + [target_filename, ], stdout=PIPE) output = p.communicate()[0].decode("utf-8") self.assertTrue(line in output) self.assertEqual(p.returncode, autopep8.EXIT_CODE_OK)