Hello community, here is the log from the commit of package python-autopep8 for openSUSE:Factory checked in at 2020-08-18 15:08:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old) and /work/SRC/openSUSE:Factory/.python-autopep8.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-autopep8" Tue Aug 18 15:08:19 2020 rev:20 rq:826935 version:1.5.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes 2020-06-10 00:49:08.787059615 +0200 +++ /work/SRC/openSUSE:Factory/.python-autopep8.new.3399/python-autopep8.changes 2020-08-18 15:08:27.059976126 +0200 @@ -1,0 +2,21 @@ +Sat Aug 15 16:46:41 UTC 2020 - Arun Persaud <a...@gmx.de> + +- update to version 1.5.4: + * Merge pull request #565 from hhatto/fix-issue-564 + * ignore SyntaxWarning in Python3.8+ when calling built-in compile() + method + * fix pytest command + * fix coverage and upload codecov + * install depends + * flake8 target only autopep8.py + * Fix pycodestyle + * Revert formatting changes outside scope of this feature + * Move the on-off tests to under unit-tests + * Correct line number weirdness + * Add tests + * Improved efficiency of search for enabled/disable + * added basic on-off functionality to autopep8 + * Merge pull request #553 from hhatto/issue-551 + * fix: ignoring w292 with in-place option + +------------------------------------------------------------------- Old: ---- autopep8-1.5.3.tar.gz New: ---- autopep8-1.5.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-autopep8.spec ++++++ --- /var/tmp/diff_new_pack.U51EpP/_old 2020-08-18 15:08:28.975976919 +0200 +++ /var/tmp/diff_new_pack.U51EpP/_new 2020-08-18 15:08:28.979976920 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-autopep8 -Version: 1.5.3 +Version: 1.5.4 Release: 0 Summary: Automatic generated to pep8 checked code License: MIT ++++++ autopep8-1.5.3.tar.gz -> autopep8-1.5.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/AUTHORS.rst new/autopep8-1.5.4/AUTHORS.rst --- old/autopep8-1.5.3/AUTHORS.rst 2017-03-07 15:47:51.000000000 +0100 +++ new/autopep8-1.5.4/AUTHORS.rst 2020-08-02 04:15:48.000000000 +0200 @@ -22,3 +22,27 @@ - Fabio Zadrozny (https://github.com/fabioz) - Alex Chernetz (https://github.com/achernet) - Marc Schlaich (https://github.com/schlamar) +- E. M. Bray (https://github.com/embray) +- Thomas Hisch (https://github.com/thisch) +- Florian Best (https://github.com/spaceone) +- Ian Clark (https://github.com/evenicoulddoit) +- Khairi Hafsham (https://github.com/khairihafsham) +- Neil Halelamien (https://github.com/neilsh) +- Hashem Nasarat (https://github.com/Hnasar) +- Hugo van Kemenade (https://github.com/hugovk) +- gmbnomis (https://github.com/gmbnomis) +- Samuel Lelièvre (https://github.com/slel) +- bigredengineer (https://github.com/bigredengineer) +- Kai Chen (https://github.com/kx-chen) +- Anthony Sottile (https://github.com/asottile) +- 秋葉 (https://github.com/Hanaasagi) +- Christian Clauss (https://github.com/cclauss) +- tobixx (https://github.com/tobixx) +- bigredengineer (https://github.com/bigredengineer) +- Bastien Gérard (https://github.com/bagerard) +- nicolasbonifas (https://github.com/nicolasbonifas) +- Andrii Yurchuk (https://github.com/Ch00k) +- José M. Guisado (https://github.com/pvxe) +- Dai Truong (https://github.com/NovaDev94) +- jnozsc (https://github.com/jnozsc) +- Edwin Shepherd (https://github.com/shardros) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/PKG-INFO new/autopep8-1.5.4/PKG-INFO --- old/autopep8-1.5.3/PKG-INFO 2020-05-31 16:15:33.755008500 +0200 +++ new/autopep8-1.5.4/PKG-INFO 2020-08-02 06:28:35.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.5.3 +Version: 1.5.4 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 @@ -14,10 +14,14 @@ :target: https://pypi.org/project/autopep8/ :alt: PyPI Version - .. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master - :target: https://travis-ci.org/hhatto/autopep8 + .. image:: https://github.com/hhatto/autopep8/workflows/Python%20package/badge.svg + :target: https://github.com/hhatto/autopep8/actions :alt: Build status + .. image:: https://codecov.io/gh/hhatto/autopep8/branch/master/graph/badge.svg + :target: https://codecov.io/gh/hhatto/autopep8 + :alt: Code Coverage + autopep8 automatically formats Python code to conform to the `PEP 8`_ style guide. It uses the pycodestyle_ utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/README.rst new/autopep8-1.5.4/README.rst --- old/autopep8-1.5.3/README.rst 2020-05-31 15:08:01.000000000 +0200 +++ new/autopep8-1.5.4/README.rst 2020-07-31 08:06:41.000000000 +0200 @@ -6,10 +6,14 @@ :target: https://pypi.org/project/autopep8/ :alt: PyPI Version -.. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master - :target: https://travis-ci.org/hhatto/autopep8 +.. image:: https://github.com/hhatto/autopep8/workflows/Python%20package/badge.svg + :target: https://github.com/hhatto/autopep8/actions :alt: Build status +.. image:: https://codecov.io/gh/hhatto/autopep8/branch/master/graph/badge.svg + :target: https://codecov.io/gh/hhatto/autopep8 + :alt: Code Coverage + autopep8 automatically formats Python code to conform to the `PEP 8`_ style guide. It uses the pycodestyle_ utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/autopep8.egg-info/PKG-INFO new/autopep8-1.5.4/autopep8.egg-info/PKG-INFO --- old/autopep8-1.5.3/autopep8.egg-info/PKG-INFO 2020-05-31 16:15:33.000000000 +0200 +++ new/autopep8-1.5.4/autopep8.egg-info/PKG-INFO 2020-08-02 06:28:35.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: autopep8 -Version: 1.5.3 +Version: 1.5.4 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 @@ -14,10 +14,14 @@ :target: https://pypi.org/project/autopep8/ :alt: PyPI Version - .. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master - :target: https://travis-ci.org/hhatto/autopep8 + .. image:: https://github.com/hhatto/autopep8/workflows/Python%20package/badge.svg + :target: https://github.com/hhatto/autopep8/actions :alt: Build status + .. image:: https://codecov.io/gh/hhatto/autopep8/branch/master/graph/badge.svg + :target: https://codecov.io/gh/hhatto/autopep8 + :alt: Code Coverage + autopep8 automatically formats Python code to conform to the `PEP 8`_ style guide. It uses the pycodestyle_ utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/autopep8.py new/autopep8-1.5.4/autopep8.py --- old/autopep8-1.5.3/autopep8.py 2020-05-31 16:00:34.000000000 +0200 +++ new/autopep8-1.5.4/autopep8.py 2020-08-02 04:24:44.000000000 +0200 @@ -58,6 +58,7 @@ import textwrap import token import tokenize +import warnings import ast try: from configparser import ConfigParser as SafeConfigParser @@ -77,7 +78,7 @@ unicode = str -__version__ = '1.5.3' +__version__ = '1.5.4' CR = '\r' @@ -92,6 +93,8 @@ BARE_EXCEPT_REGEX = re.compile(r'except\s*:') STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)\s.*\):') DOCSTRING_START_REGEX = re.compile(r'^u?r?(?P<kind>["\']{3})') +ENABLE_REGEX = re.compile(r'# *(fmt|autopep8): *on') +DISABLE_REGEX = re.compile(r'# *(fmt|autopep8): *off') EXIT_CODE_OK = 0 EXIT_CODE_ERROR = 1 @@ -3222,6 +3225,73 @@ return False +def find_with_line_numbers(pattern, contents): + """A wrapper around 're.finditer' to find line numbers. + + Returns a list of line numbers where pattern was found in contents. + """ + matches = list(re.finditer(pattern, contents)) + if not matches: + return [] + + end = matches[-1].start() + + # -1 so a failed `rfind` maps to the first line. + newline_offsets = { + -1: 0 + } + for line_num, m in enumerate(re.finditer(r'\n', contents), 1): + offset = m.start() + if offset > end: + break + newline_offsets[offset] = line_num + + def get_line_num(match, contents): + """Get the line number of string in a files contents. + + Failing to find the newline is OK, -1 maps to 0 + + """ + newline_offset = contents.rfind('\n', 0, match.start()) + return newline_offsets[newline_offset] + + return [get_line_num(match, contents) + 1 for match in matches] + + +def get_disabled_ranges(source): + """Returns a list of tuples representing the disabled ranges. + + If disabled and no re-enable will disable for rest of file. + + """ + enable_line_nums = find_with_line_numbers(ENABLE_REGEX, source) + disable_line_nums = find_with_line_numbers(DISABLE_REGEX, source) + total_lines = len(re.findall("\n", source)) + 1 + + enable_commands = {} + for num in enable_line_nums: + enable_commands[num] = True + for num in disable_line_nums: + enable_commands[num] = False + + disabled_ranges = [] + currently_enabled = True + disabled_start = None + + for line, commanded_enabled in sorted(enable_commands.items()): + if currently_enabled is True and commanded_enabled is False: + disabled_start = line + currently_enabled = False + elif currently_enabled is False and commanded_enabled is True: + disabled_ranges.append((disabled_start, line)) + currently_enabled = True + + if currently_enabled is False: + disabled_ranges.append((disabled_start, total_lines)) + + return disabled_ranges + + def filter_results(source, results, aggressive): """Filter out spurious reports from pycodestyle. @@ -3235,6 +3305,14 @@ commented_out_code_line_numbers = commented_out_code_lines(source) + # 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) + ] + has_e901 = any(result['id'].lower() == 'e901' for result in results) for r in results: @@ -3335,12 +3413,18 @@ if token_type == tokenize.COMMENT: stripped_line = token_string.lstrip('#').strip() - if ( - ' ' in stripped_line and - '#' not in stripped_line and - check_syntax(stripped_line) - ): - line_numbers.append(start_row) + with warnings.catch_warnings(): + # ignore SyntaxWarning in Python3.8+ + # refs: + # https://bugs.python.org/issue15248 + # https://docs.python.org/3.8/whatsnew/3.8.html#other-language-changes + warnings.filterwarnings("ignore", category=SyntaxWarning) + if ( + ' ' in stripped_line and + '#' not in stripped_line and + check_syntax(stripped_line) + ): + line_numbers.append(start_row) except (SyntaxError, tokenize.TokenError): pass @@ -3534,7 +3618,13 @@ elif options.in_place: original = "".join(original_source).splitlines() fixed = fixed_source.splitlines() - if original != fixed: + original_source_last_line = ( + original_source[-1].split("\n")[-1] if original_source else "" + ) + fixed_source_last_line = fixed_source.split("\n")[-1] + if original != fixed or ( + original_source_last_line != fixed_source_last_line + ): with open_with_encoding(filename, 'w', encoding=encoding) as fp: fp.write(fixed_source) return fixed_source diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.5.3/test/test_autopep8.py new/autopep8-1.5.4/test/test_autopep8.py --- old/autopep8-1.5.3/test/test_autopep8.py 2020-05-31 16:00:11.000000000 +0200 +++ new/autopep8-1.5.4/test/test_autopep8.py 2020-07-31 08:06:41.000000000 +0200 @@ -5175,6 +5175,216 @@ with autopep8_context(line) as result: self.assertEqual(line, result) + def test_autopep8_disable(self): + test_code = """\ +# autopep8: off +def f(): + aaaaaaaaaaa.bbbbbbb([ + ('xxxxxxxxxx', 'yyyyyy', + 'Heaven hath no wrath like love to hatred turned. Nor hell a fury like a woman scorned.'), + ('xxxxxxx', 'yyyyyyyyyyy', "To the last I grapple with thee. From hell's heart I stab at thee. For hate's sake I spit my last breath at thee!")]) +# autopep8: on +""" + expected_output = """\ +# autopep8: off +def f(): + aaaaaaaaaaa.bbbbbbb([ + ('xxxxxxxxxx', 'yyyyyy', + 'Heaven hath no wrath like love to hatred turned. Nor hell a fury like a woman scorned.'), + ('xxxxxxx', 'yyyyyyyyyyy', "To the last I grapple with thee. From hell's heart I stab at thee. For hate's sake I spit my last breath at thee!")]) +# autopep8: on +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_disable(self): + test_code = """\ +# fmt: off +def f(): + aaaaaaaaaaa.bbbbbbb([ + ('xxxxxxxxxx', 'yyyyyy', + 'Heaven hath no wrath like love to hatred turned. Nor hell a fury like a woman scorned.'), + ('xxxxxxx', 'yyyyyyyyyyy', "To the last I grapple with thee. From hell's heart I stab at thee. For hate's sake I spit my last breath at thee!")]) +# fmt: on +""" + expected_output = """\ +# fmt: off +def f(): + aaaaaaaaaaa.bbbbbbb([ + ('xxxxxxxxxx', 'yyyyyy', + 'Heaven hath no wrath like love to hatred turned. Nor hell a fury like a woman scorned.'), + ('xxxxxxx', 'yyyyyyyyyyy', "To the last I grapple with thee. From hell's heart I stab at thee. For hate's sake I spit my last breath at thee!")]) +# fmt: on +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_disable_without_reenable(self): + test_code = """\ +# fmt: off +print(123) +""" + expected_output = """\ +# fmt: off +print(123) +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_disable_with_double_reenable(self): + test_code = """\ +# fmt: off +print( 123 ) +# fmt: on +print( 123 ) +# fmt: on +print( 123 ) +""" + expected_output = """\ +# fmt: off +print( 123 ) +# fmt: on +print(123) +# fmt: on +print(123) +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_fmt_double_disable_and_reenable(self): + test_code = """\ +# fmt: off +print( 123 ) +# fmt: off +print( 123 ) +# fmt: on +print( 123 ) +""" + expected_output = """\ +# fmt: off +print( 123 ) +# fmt: off +print( 123 ) +# fmt: on +print(123) +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + + def test_general_disable(self): + test_code = """\ +# fmt: off + +import math, sys; + +def example1(): + # This is a long comment. This should be wrapped to fit within 72 characters. + some_tuple=( 1,2, 3,'a' ); + some_variable={'long':'Long code lines should be wrapped within 79 characters.', + 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], + 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, + 20,300,40000,500000000,60000000000000000]}} + return (some_tuple, some_variable) +def example2(): return {'has_key() is deprecated':True}.has_key( + {'f':2}.has_key('')); +class Example3( object ): + def __init__ ( self, bar ): + # Comments should have a space after the hash. + if bar : bar+=1; bar=bar* bar ; return bar + else: + some_string = ''' + Indentation in multiline strings should not be touched. +Only actual code should be reindented. +''' + return (sys.path, some_string) +# fmt: on + +import math, sys; + +def example1(): + # This is a long comment. This should be wrapped to fit within 72 characters. + some_tuple=( 1,2, 3,'a' ); + some_variable={'long':'Long code lines should be wrapped within 79 characters.', + 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], + 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, + 20,300,40000,500000000,60000000000000000]}} + return (some_tuple, some_variable) +def example2(): return {'has_key() is deprecated':True}.has_key( + {'f':2}.has_key('')); +class Example3( object ): + def __init__ ( self, bar ): + # Comments should have a space after the hash. + if bar : bar+=1; bar=bar* bar ; return bar + else: + some_string = ''' + Indentation in multiline strings should not be touched. +Only actual code should be reindented. +''' + return (sys.path, some_string) + + +""" + expected_output = """\ +# fmt: off + +import sys +import math +import math, sys; + +def example1(): + # This is a long comment. This should be wrapped to fit within 72 characters. + some_tuple=( 1,2, 3,'a' ); + some_variable={'long':'Long code lines should be wrapped within 79 characters.', + 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], + 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, + 20,300,40000,500000000,60000000000000000]}} + return (some_tuple, some_variable) +def example2(): return {'has_key() is deprecated':True}.has_key( + {'f':2}.has_key('')); +class Example3( object ): + def __init__ ( self, bar ): + # Comments should have a space after the hash. + if bar : bar+=1; bar=bar* bar ; return bar + else: + some_string = ''' + Indentation in multiline strings should not be touched. +Only actual code should be reindented. +''' + return (sys.path, some_string) +# fmt: on + + +def example1(): + # This is a long comment. This should be wrapped to fit within 72 characters. + some_tuple = (1, 2, 3, 'a') + some_variable = {'long': 'Long code lines should be wrapped within 79 characters.', + 'other': [math.pi, 100, 200, 300, 9876543210, 'This is a long string that goes on'], + 'more': {'inner': 'This whole logical line should be wrapped.', some_tuple: [1, + 20, 300, 40000, 500000000, 60000000000000000]}} + return (some_tuple, some_variable) + + +def example2(): return {'has_key() is deprecated': True}.has_key( + {'f': 2}.has_key('')) + + +class Example3(object): + def __init__(self, bar): + # Comments should have a space after the hash. + if bar: + bar += 1 + bar = bar * bar + return bar + else: + some_string = ''' + Indentation in multiline strings should not be touched. +Only actual code should be reindented. +''' + return (sys.path, some_string) +""" + with autopep8_context(test_code) as result: + self.assertEqual(expected_output, result) + class UtilityFunctionTests(unittest.TestCase): @@ -5360,6 +5570,28 @@ self.assertEqual(err, b'') self.assertEqual(p.returncode, autopep8.EXIT_CODE_OK) + def test_in_place_no_modifications_no_writes_with_empty_file(self): + with temporary_file_context('') as filename: + # ensure that noops do not do writes by making writing an error + os.chmod(filename, 0o444) + p = Popen( + list(AUTOPEP8_CMD_TUPLE) + [filename, '--in-place'], + stderr=PIPE, + ) + _, err = p.communicate() + self.assertEqual(err, b'') + self.assertEqual(p.returncode, autopep8.EXIT_CODE_OK) + + def test_in_place_with_w292(self): + line = "import os" + fixed = "import os\n" + + with temporary_file_context(line) as filename: + p = Popen(list(AUTOPEP8_CMD_TUPLE) + [filename, '--in-place']) + p.wait() + with open(filename) as f: + self.assertEqual(fixed, f.read()) + def test_in_place_with_exit_code_option(self): line = "'abc' \n" fixed = "'abc'\n"