diff -Nru autopep8-1.5.4/autopep8.py autopep8-1.5.5/autopep8.py --- autopep8-1.5.4/autopep8.py 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/autopep8.py 2021-02-04 06:04:57.000000000 +0000 @@ -67,7 +67,6 @@ from ConfigParser import SafeConfigParser from ConfigParser import Error -import toml import pycodestyle from pycodestyle import STARTSWITH_INDENT_STATEMENT_REGEX @@ -78,7 +77,7 @@ unicode = str -__version__ = '1.5.4' +__version__ = '1.5.5' CR = '\r' @@ -1385,56 +1384,10 @@ next_line[next_line_indent:]) def fix_w605(self, result): - (line_index, _, target) = get_index_offset_contents(result, - self.source) - try: - tokens = list(generate_tokens(target)) - except (SyntaxError, tokenize.TokenError): - return - for (pos, _msg) in get_w605_position(tokens): - if target[pos - 1] == "r": - # ignore special case - if self.options.verbose: - print("invalid line: line_number={}, line: {}".format( - line_index + 1, target)) - return - self.source[line_index] = '{}r{}'.format( - target[:pos], target[pos:]) - - -def get_w605_position(tokens): - """workaround get pointing out position by W605.""" - # TODO: When this PR(*) change is released, use pos of pycodestyle - # *: https://github.com/PyCQA/pycodestyle/pull/747 - valid = [ - '\n', '\\', '\'', '"', 'a', 'b', 'f', 'n', 'r', 't', 'v', - '0', '1', '2', '3', '4', '5', '6', '7', 'x', - - # Escape sequences only recognized in string literals - 'N', 'u', 'U', - ] - - for token_type, text, start_pos, _end_pos, _line in tokens: - if token_type == tokenize.STRING: - quote = text[-3:] if text[-3:] in ('"""', "'''") else text[-1] - # Extract string modifiers (e.g. u or r) - quote_pos = text.index(quote) - prefix = text[:quote_pos].lower() - start = quote_pos + len(quote) - string = text[start:-len(quote)] - - if 'r' not in prefix: - pos = string.find('\\') - while pos >= 0: - pos += 1 - if string[pos] not in valid: - yield ( - # No need to search line, token stores position - start_pos[1], - "W605 invalid escape sequence '\\%s'" % - string[pos], - ) - pos = string.find('\\', pos + 1) + (line_index, offset, target) = get_index_offset_contents(result, + self.source) + self.source[line_index] = '{}\\{}'.format( + target[:offset + 1], target[offset + 1:]) def get_module_imports_on_top_of_file(source, import_line_index): @@ -3985,6 +3938,8 @@ def read_pyproject_toml(args, parser): """Read pyproject.toml and load configuration.""" + import toml + config = None if os.path.exists(args.global_config): diff -Nru autopep8-1.5.4/debian/changelog autopep8-1.5.5/debian/changelog --- autopep8-1.5.4/debian/changelog 2020-08-10 08:35:28.000000000 +0000 +++ autopep8-1.5.5/debian/changelog 2021-02-04 10:16:29.000000000 +0000 @@ -1,3 +1,17 @@ +autopep8 (1.5.5-1) unstable; urgency=medium + + [ Ondřej Nový ] + * d/control: Update Vcs-* fields with new Debian Python Team Salsa + layout. + + [ Sandro Tosi ] + * Use the new Debian Python Team contact name and address + + [ Sylvestre Ledru ] + * New upstream release + + -- Sylvestre Ledru Thu, 04 Feb 2021 11:16:29 +0100 + autopep8 (1.5.4-1) unstable; urgency=low * New upstream release diff -Nru autopep8-1.5.4/debian/control autopep8-1.5.5/debian/control --- autopep8-1.5.4/debian/control 2020-08-10 08:34:52.000000000 +0000 +++ autopep8-1.5.5/debian/control 2021-02-04 10:15:37.000000000 +0000 @@ -1,6 +1,6 @@ Source: autopep8 Maintainer: Sylvestre Ledru -Uploaders: Debian Python Modules Team +Uploaders: Debian Python Team Section: python Priority: optional Build-Depends: python3-setuptools, python3-all, dh-sequence-python3, @@ -8,8 +8,8 @@ help2man, python3-toml Standards-Version: 4.2.1 Homepage: https://pypi.python.org/pypi/autopep8/ -Vcs-Git: https://salsa.debian.org/python-team/modules/autopep8.git -Vcs-Browser: https://salsa.debian.org/python-team/modules/autopep8 +Vcs-Git: https://salsa.debian.org/python-team/packages/autopep8.git +Vcs-Browser: https://salsa.debian.org/python-team/packages/autopep8 Package: python3-autopep8 Architecture: all diff -Nru autopep8-1.5.4/.github/workflows/python-package.yml autopep8-1.5.5/.github/workflows/python-package.yml --- autopep8-1.5.4/.github/workflows/python-package.yml 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/.github/workflows/python-package.yml 2021-02-04 06:04:57.000000000 +0000 @@ -15,7 +15,7 @@ runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3] steps: - uses: actions/checkout@v2 diff -Nru autopep8-1.5.4/.github/workflows/python-publish.yml autopep8-1.5.5/.github/workflows/python-publish.yml --- autopep8-1.5.4/.github/workflows/python-publish.yml 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/.github/workflows/python-publish.yml 2021-02-04 06:04:57.000000000 +0000 @@ -9,7 +9,6 @@ jobs: deploy: - needs: test runs-on: ubuntu-latest steps: diff -Nru autopep8-1.5.4/README.rst autopep8-1.5.5/README.rst --- autopep8-1.5.4/README.rst 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/README.rst 2021-02-04 06:04:57.000000000 +0000 @@ -384,7 +384,7 @@ Test cases are in ``test/test_autopep8.py``. They can be run directly via ``python test/test_autopep8.py`` or via tox_. The latter is useful for testing against multiple Python interpreters. (We currently test against -CPython versions 2.7, 3.4, 3.5, 3.6 and 3.7. We also test against PyPy.) +CPython versions 2.7, 3.6 3.7 and 3.8. We also test against PyPy.) .. _`tox`: https://pypi.org/project/tox/ diff -Nru autopep8-1.5.4/setup.py autopep8-1.5.5/setup.py --- autopep8-1.5.4/setup.py 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/setup.py 2021-02-04 06:04:57.000000000 +0000 @@ -43,8 +43,6 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', diff -Nru autopep8-1.5.4/test/test_autopep8.py autopep8-1.5.5/test/test_autopep8.py --- autopep8-1.5.4/test/test_autopep8.py 2020-08-02 02:25:16.000000000 +0000 +++ autopep8-1.5.5/test/test_autopep8.py 2021-02-04 06:04:57.000000000 +0000 @@ -5037,32 +5037,44 @@ def test_w605_simple(self): line = "escape = '\\.jpg'\n" - fixed = "escape = r'\\.jpg'\n" + fixed = "escape = '\\\\.jpg'\n" with autopep8_context(line, options=['--aggressive']) as result: self.assertEqual(fixed, result) def test_w605_identical_token(self): - # ***NOTE***: The --pep8-passes option is requred to prevent an infinite loop in + # ***NOTE***: The --pep8-passes option is required to prevent an infinite loop in # the old, failing code. DO NOT REMOVE. line = "escape = foo('\\.bar', '\\.kilroy')\n" - fixed = "escape = foo(r'\\.bar', r'\\.kilroy')\n" + fixed = "escape = foo('\\\\.bar', '\\\\.kilroy')\n" with autopep8_context(line, options=['--aggressive', '--pep8-passes', '5']) as result: self.assertEqual(fixed, result, "Two tokens get r added") - line = "escape = foo('\\.bar', r'\\.kilroy')\n" - fixed = "escape = foo(r'\\.bar', r'\\.kilroy')\n" + line = "escape = foo('\\.bar', '\\\\.kilroy')\n" + fixed = "escape = foo('\\\\.bar', '\\\\.kilroy')\n" with autopep8_context(line, options=['--aggressive', '--pep8-passes', '5']) as result: self.assertEqual(fixed, result, "r not added if already there") # Test Case to catch bad behavior reported in Issue #449 line = "escape = foo('\\.bar', '\\.bar')\n" - fixed = "escape = foo(r'\\.bar', r'\\.bar')\n" + fixed = "escape = foo('\\\\.bar', '\\\\.bar')\n" with autopep8_context(line, options=['--aggressive', '--pep8-passes', '5']) as result: self.assertEqual(fixed, result) def test_w605_with_invalid_syntax(self): line = "escape = rr'\\.jpg'\n" - fixed = "escape = rr'\\.jpg'\n" + fixed = "escape = rr'\\\\.jpg'\n" + with autopep8_context(line, options=['--aggressive']) as result: + self.assertEqual(fixed, result) + + def test_w605_with_multilines(self): + line = """\ +regex = '\\d+(\\.\\d+){3}$' +foo = validators.RegexValidator( + regex='\\d+(\\.\\d+){3}$')\n""" # noqa + fixed = """\ +regex = '\\\\d+(\\\\.\\\\d+){3}$' +foo = validators.RegexValidator( + regex='\\\\d+(\\\\.\\\\d+){3}$')\n""" with autopep8_context(line, options=['--aggressive']) as result: self.assertEqual(fixed, result)