Hello community,
here is the log from the commit of package python-autopep8 for openSUSE:Factory checked in at 2018-09-04 22:56:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old)
and /work/SRC/openSUSE:Factory/.python-autopep8.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-autopep8"
Tue Sep 4 22:56:18 2018 rev:12 rq:632808 version:1.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes 2018-04-02 22:49:28.817292852 +0200
+++ /work/SRC/openSUSE:Factory/.python-autopep8.new/python-autopep8.changes 2018-09-04 22:56:19.993034338 +0200
@@ -1,0 +2,35 @@
+Mon Sep 3 09:03:49 UTC 2018 - Tomáš Chvátal
+
+- Install license
+- Delete old archive
+
+-------------------------------------------------------------------
+Sat Sep 1 18:31:27 UTC 2018 - arun@gmx.de
+
+- update to version 1.4:
+ * py37
+ * W690 add DEFAULT_IGNORE. (because Python3 is mainstream now)
+ * strict pep8
+ * update readme
+ * fix E702 is not running in case of README.rst example
+ * add unit test for e128 with -aaa option
+ * fix exception in fix_w503, when do not pointing out W503
+ * fix E305, when E303 and E305 are detected on the subsequent line
+ * env: PEP8_VERSION=pypi,github
+ * Travis CI: Add Python 3.7 to the testing
+ * update acid test output data
+ * seperate to e113 and e116 fixed method
+ * Update links to PyPI in README.rst
+ * add W605 fixed method
+ * add unit test for w605 fixed method
+ * Make test_e225_with_indentation_fix() actually use the fixer for
+ E225
+ * Add fixer for E252 "Missing whitespace around parameter equals"
+ * ix: case that W503 in a continuous 5 or more lines
+ * add test case for W503 in a continuous 5 or more lines
+ * fix e731 with case of default argument
+ * add test for e731 with default arguments
+ * fix broken coverage script
+ * Handle ValueError from check_syntax
+
+-------------------------------------------------------------------
Old:
----
autopep8-1.3.5.tar.gz
New:
----
autopep8-1.4.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-autopep8.spec ++++++
--- /var/tmp/diff_new_pack.T7iIfR/_old 2018-09-04 22:56:20.413035772 +0200
+++ /var/tmp/diff_new_pack.T7iIfR/_new 2018-09-04 22:56:20.413035772 +0200
@@ -18,14 +18,13 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-autopep8
-Version: 1.3.5
+Version: 1.4
Release: 0
Summary: Automatic generated to pep8 checked code
License: MIT
Group: Development/Languages/Python
-Url: https://github.com/hhatto/autopep8
+URL: https://github.com/hhatto/autopep8
Source: https://files.pythonhosted.org/packages/source/a/autopep8/autopep8-%{version}.tar.gz
-# Test requirements:
BuildRequires: %{python_module pycodestyle >= 2.3}
BuildRequires: %{python_module setuptools}
BuildRequires: python-rpm-macros
@@ -33,7 +32,6 @@
Requires: python-setuptools
Requires(post): update-alternatives
Requires(postun): update-alternatives
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%python_subpackages
@@ -53,7 +51,6 @@
%python_clone -a %{buildroot}%{_bindir}/autopep8
%check
-# need to set locale to avoid UnicodeEncodeError
export LANG="en_US.UTF-8"
%python_exec setup.py test -q
@@ -69,7 +66,7 @@
%python_uninstall_alternative autopep8
%files %{python_files}
-%defattr(-,root,root,-)
+%license LICENSE
%doc README.rst
%python_alternative %{_bindir}/autopep8
%pycache_only %{python_sitelib}/__pycache__/*
++++++ autopep8-1.3.5.tar.gz -> autopep8-1.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/PKG-INFO new/autopep8-1.4/PKG-INFO
--- old/autopep8-1.3.5/PKG-INFO 2018-03-30 09:32:39.000000000 +0200
+++ new/autopep8-1.4/PKG-INFO 2018-09-01 18:03:14.000000000 +0200
@@ -1,18 +1,17 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.3.5
+Version: 1.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
Author-email: hhatto.jp@gmail.com
License: Expat License
-Description-Content-Type: UNKNOWN
Description: ========
autopep8
========
.. image:: https://img.shields.io/pypi/v/autopep8.svg
- :target: https://pypi.python.org/pypi/autopep8
+ :target: https://pypi.org/project/autopep8/
:alt: PyPI Version
.. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master
@@ -120,7 +119,6 @@
class Example3(object):
-
def __init__(self, bar):
# Comments should have a space after the hash.
if bar:
@@ -140,7 +138,7 @@
[--ignore-local-config] [-r] [-j n] [-p n] [-a]
[--experimental] [--exclude globs] [--list-fixes]
[--ignore errors] [--select errors] [--max-line-length n]
- [--line-range line line]
+ [--line-range line line] [--hang-closing]
[files [files ...]]
Automatically formats Python code to conform to the PEP 8 style guide.
@@ -176,13 +174,15 @@
--exclude globs exclude file/directory names that match these comma-
separated globs
--list-fixes list codes for fixes; used by --ignore and --select
- --ignore errors do not fix these errors/warnings (default: E24)
+ --ignore errors do not fix these errors/warnings (default:
+ E226,E24,W503)
--select errors fix only these errors/warnings (e.g. E4,W)
--max-line-length n set maximum allowed line length (default: 79)
--line-range line line, --range line line
only fix errors found within this inclusive range of
line numbers (e.g. 1 99); line numbers are indexed at
1
+ --hang-closing hang-closing option passed to pycodestyle
Features
@@ -211,6 +211,7 @@
E241 - Fix extraneous whitespace around keywords.
E242 - Remove extraneous whitespace around operator.
E251 - Remove whitespace around parameter '=' sign.
+ E252 - Missing whitespace around parameter equals.
E26 - Fix spacing after comment hash for inline comments.
E265 - Fix spacing after comment hash for block comments.
E27 - Fix extraneous whitespace around keywords.
@@ -331,7 +332,7 @@
testing against multiple Python interpreters. (We currently test against
CPython versions 2.7, 3.4, 3.5 and 3.6. We also test against PyPy.)
- .. _`tox`: https://pypi.python.org/pypi/tox
+ .. _`tox`: https://pypi.org/project/tox/
Broad spectrum testing is available via ``test/acid.py``. This script runs
autopep8 against Python code and checks for correctness and completeness of the
@@ -363,7 +364,7 @@
* `Travis CI`_
* Coveralls_
- .. _PyPI: https://pypi.python.org/pypi/autopep8/
+ .. _PyPI: https://pypi.org/project/autopep8/
.. _GitHub: https://github.com/hhatto/autopep8
.. _`Travis CI`: https://travis-ci.org/hhatto/autopep8
.. _`Coveralls`: https://coveralls.io/r/hhatto/autopep8
@@ -382,5 +383,6 @@
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/README.rst new/autopep8-1.4/README.rst
--- old/autopep8-1.3.5/README.rst 2018-03-30 07:24:40.000000000 +0200
+++ new/autopep8-1.4/README.rst 2018-09-01 17:05:18.000000000 +0200
@@ -3,7 +3,7 @@
========
.. image:: https://img.shields.io/pypi/v/autopep8.svg
- :target: https://pypi.python.org/pypi/autopep8
+ :target: https://pypi.org/project/autopep8/
:alt: PyPI Version
.. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master
@@ -111,7 +111,6 @@
class Example3(object):
-
def __init__(self, bar):
# Comments should have a space after the hash.
if bar:
@@ -131,7 +130,7 @@
[--ignore-local-config] [-r] [-j n] [-p n] [-a]
[--experimental] [--exclude globs] [--list-fixes]
[--ignore errors] [--select errors] [--max-line-length n]
- [--line-range line line]
+ [--line-range line line] [--hang-closing]
[files [files ...]]
Automatically formats Python code to conform to the PEP 8 style guide.
@@ -167,13 +166,15 @@
--exclude globs exclude file/directory names that match these comma-
separated globs
--list-fixes list codes for fixes; used by --ignore and --select
- --ignore errors do not fix these errors/warnings (default: E24)
+ --ignore errors do not fix these errors/warnings (default:
+ E226,E24,W503)
--select errors fix only these errors/warnings (e.g. E4,W)
--max-line-length n set maximum allowed line length (default: 79)
--line-range line line, --range line line
only fix errors found within this inclusive range of
line numbers (e.g. 1 99); line numbers are indexed at
1
+ --hang-closing hang-closing option passed to pycodestyle
Features
@@ -202,6 +203,7 @@
E241 - Fix extraneous whitespace around keywords.
E242 - Remove extraneous whitespace around operator.
E251 - Remove whitespace around parameter '=' sign.
+ E252 - Missing whitespace around parameter equals.
E26 - Fix spacing after comment hash for inline comments.
E265 - Fix spacing after comment hash for block comments.
E27 - Fix extraneous whitespace around keywords.
@@ -322,7 +324,7 @@
testing against multiple Python interpreters. (We currently test against
CPython versions 2.7, 3.4, 3.5 and 3.6. We also test against PyPy.)
-.. _`tox`: https://pypi.python.org/pypi/tox
+.. _`tox`: https://pypi.org/project/tox/
Broad spectrum testing is available via ``test/acid.py``. This script runs
autopep8 against Python code and checks for correctness and completeness of the
@@ -354,7 +356,7 @@
* `Travis CI`_
* Coveralls_
-.. _PyPI: https://pypi.python.org/pypi/autopep8/
+.. _PyPI: https://pypi.org/project/autopep8/
.. _GitHub: https://github.com/hhatto/autopep8
.. _`Travis CI`: https://travis-ci.org/hhatto/autopep8
.. _`Coveralls`: https://coveralls.io/r/hhatto/autopep8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/autopep8.egg-info/PKG-INFO new/autopep8-1.4/autopep8.egg-info/PKG-INFO
--- old/autopep8-1.3.5/autopep8.egg-info/PKG-INFO 2018-03-30 09:32:39.000000000 +0200
+++ new/autopep8-1.4/autopep8.egg-info/PKG-INFO 2018-09-01 18:03:14.000000000 +0200
@@ -1,18 +1,17 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.3.5
+Version: 1.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
Author-email: hhatto.jp@gmail.com
License: Expat License
-Description-Content-Type: UNKNOWN
Description: ========
autopep8
========
.. image:: https://img.shields.io/pypi/v/autopep8.svg
- :target: https://pypi.python.org/pypi/autopep8
+ :target: https://pypi.org/project/autopep8/
:alt: PyPI Version
.. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master
@@ -120,7 +119,6 @@
class Example3(object):
-
def __init__(self, bar):
# Comments should have a space after the hash.
if bar:
@@ -140,7 +138,7 @@
[--ignore-local-config] [-r] [-j n] [-p n] [-a]
[--experimental] [--exclude globs] [--list-fixes]
[--ignore errors] [--select errors] [--max-line-length n]
- [--line-range line line]
+ [--line-range line line] [--hang-closing]
[files [files ...]]
Automatically formats Python code to conform to the PEP 8 style guide.
@@ -176,13 +174,15 @@
--exclude globs exclude file/directory names that match these comma-
separated globs
--list-fixes list codes for fixes; used by --ignore and --select
- --ignore errors do not fix these errors/warnings (default: E24)
+ --ignore errors do not fix these errors/warnings (default:
+ E226,E24,W503)
--select errors fix only these errors/warnings (e.g. E4,W)
--max-line-length n set maximum allowed line length (default: 79)
--line-range line line, --range line line
only fix errors found within this inclusive range of
line numbers (e.g. 1 99); line numbers are indexed at
1
+ --hang-closing hang-closing option passed to pycodestyle
Features
@@ -211,6 +211,7 @@
E241 - Fix extraneous whitespace around keywords.
E242 - Remove extraneous whitespace around operator.
E251 - Remove whitespace around parameter '=' sign.
+ E252 - Missing whitespace around parameter equals.
E26 - Fix spacing after comment hash for inline comments.
E265 - Fix spacing after comment hash for block comments.
E27 - Fix extraneous whitespace around keywords.
@@ -331,7 +332,7 @@
testing against multiple Python interpreters. (We currently test against
CPython versions 2.7, 3.4, 3.5 and 3.6. We also test against PyPy.)
- .. _`tox`: https://pypi.python.org/pypi/tox
+ .. _`tox`: https://pypi.org/project/tox/
Broad spectrum testing is available via ``test/acid.py``. This script runs
autopep8 against Python code and checks for correctness and completeness of the
@@ -363,7 +364,7 @@
* `Travis CI`_
* Coveralls_
- .. _PyPI: https://pypi.python.org/pypi/autopep8/
+ .. _PyPI: https://pypi.org/project/autopep8/
.. _GitHub: https://github.com/hhatto/autopep8
.. _`Travis CI`: https://travis-ci.org/hhatto/autopep8
.. _`Coveralls`: https://coveralls.io/r/hhatto/autopep8
@@ -382,5 +383,6 @@
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/autopep8.py new/autopep8-1.4/autopep8.py
--- old/autopep8-1.3.5/autopep8.py 2018-03-30 07:20:51.000000000 +0200
+++ new/autopep8-1.4/autopep8.py 2018-09-01 18:00:55.000000000 +0200
@@ -67,7 +67,7 @@
unicode = str
-__version__ = '1.3.5'
+__version__ = '1.4'
CR = '\r'
@@ -76,7 +76,7 @@
PYTHON_SHEBANG_REGEX = re.compile(r'^#!.*\bpython[23]?\b\s*$')
-LAMBDA_REGEX = re.compile(r'([\w.]+)\s=\slambda\s*([\(\)\w,\s.]*):')
+LAMBDA_REGEX = re.compile(r'([\w.]+)\s=\slambda\s*([\(\)=\w,\s.]*):')
COMPARE_NEGATIVE_REGEX = re.compile(r'\b(not)\s+([^][)(}{]+?)\s+(in|is)\s')
COMPARE_NEGATIVE_REGEX_THROUGH = re.compile(r'\b(not\s+in|is\s+not)\s')
BARE_EXCEPT_REGEX = re.compile(r'except\s*:')
@@ -94,7 +94,7 @@
])
-DEFAULT_IGNORE = 'E226,E24,W503' # TODO: use pycodestyle.DEFAULT_IGNORE
+DEFAULT_IGNORE = 'E226,E24,W503,W690' # TODO: use pycodestyle.DEFAULT_IGNORE
DEFAULT_INDENT_SIZE = 4
SELECTED_GLOBAL_FIXED_METHOD_CODES = ['W602', ]
@@ -407,10 +407,10 @@
- e211
- e221,e222,e223,e224,e225
- e231
- - e251
+ - e251,e252
- e261,e262
- e271,e272,e273,e274
- - e301,e302,e303,e304,e306
+ - e301,e302,e303,e304,e305,e306
- e401
- e502
- e701,e702,e703,e704
@@ -442,7 +442,6 @@
# Many fixers are the same even though pycodestyle categorizes them
# differently.
self.fix_e115 = self.fix_e112
- self.fix_e116 = self.fix_e113
self.fix_e121 = self._fix_reindent
self.fix_e122 = self._fix_reindent
self.fix_e123 = self._fix_reindent
@@ -463,6 +462,7 @@
self.fix_e228 = self.fix_e225
self.fix_e241 = self.fix_e271
self.fix_e242 = self.fix_e224
+ self.fix_e252 = self.fix_e225
self.fix_e261 = self.fix_e262
self.fix_e272 = self.fix_e271
self.fix_e273 = self.fix_e271
@@ -602,6 +602,14 @@
self.source[line_index] = self.indent_word + target
def fix_e113(self, result):
+ """Fix unexpected indentation."""
+ line_index = result['line'] - 1
+ target = self.source[line_index]
+ indent = _get_indentation(target)
+ stripped = target.lstrip()
+ self.source[line_index] = indent[1:] + stripped
+
+ def fix_e116(self, result):
"""Fix over-indented comments."""
line_index = result['line'] - 1
target = self.source[line_index]
@@ -798,21 +806,36 @@
def fix_e305(self, result):
"""Add missing 2 blank lines after end of function or class."""
- cr = '\n'
- # check comment line
+ add_delete_linenum = 2 - int(result['info'].split()[-1])
+ cnt = 0
offset = result['line'] - 2
- while True:
- if offset < 0:
- break
- line = self.source[offset].lstrip()
- if not line:
- break
- if line[0] != '#':
- break
- offset -= 1
- offset += 1
- self.source[offset] = cr + self.source[offset]
- return [1 + offset] # Line indexed at 1.
+ modified_lines = []
+ if add_delete_linenum < 0:
+ # delete cr
+ add_delete_linenum = abs(add_delete_linenum)
+ while cnt < add_delete_linenum and offset >= 0:
+ if not self.source[offset].strip():
+ self.source[offset] = ''
+ modified_lines.append(1 + offset) # Line indexed at 1
+ cnt += 1
+ offset -= 1
+ else:
+ # add cr
+ cr = '\n'
+ # check comment line
+ while True:
+ if offset < 0:
+ break
+ line = self.source[offset].lstrip()
+ if not line:
+ break
+ if line[0] != '#':
+ break
+ offset -= 1
+ offset += 1
+ self.source[offset] = cr + self.source[offset]
+ modified_lines.append(1 + offset) # Line indexed at 1.
+ return modified_lines
def fix_e401(self, result):
"""Put imports on separate lines."""
@@ -945,7 +968,8 @@
# Avoid applying this when indented.
# https://docs.python.org/reference/compound_stmts.html
for line in logical_lines:
- if ':' in line and STARTSWITH_DEF_REGEX.match(line):
+ if (result['id'] == 'E702' and ':' in line
+ and STARTSWITH_DEF_REGEX.match(line)):
return []
line_index = result['line'] - 1
@@ -1195,7 +1219,7 @@
break
i = target.index(one_string_token)
self.source[line_index] = '{}{}'.format(
- target[:i], target[i + len(one_string_token):])
+ target[:i], target[i + len(one_string_token):].lstrip())
nl = find_newline(self.source[line_index - 1:line_index])
before_line = self.source[line_index - 1]
bl = before_line.index(nl)
@@ -1207,6 +1231,48 @@
self.source[line_index - 1] = '{} {}{}'.format(
before_line[:bl], one_string_token, before_line[bl:])
+ def fix_w605(self, result):
+ (line_index, _, target) = get_index_offset_contents(result,
+ self.source)
+ tokens = list(generate_tokens(target))
+ for (pos, _msg) in get_w605_position(tokens):
+ 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, end, 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 (
+ line.find(text),
+ "W605 invalid escape sequence '\\%s'" %
+ string[pos],
+ )
+ pos = string.find('\\', pos + 1)
+
def get_index_offset_contents(result, source):
"""Return (line_index, column_offset, line_contents)."""
@@ -1585,7 +1651,6 @@
# We need to shorten lines last since the logical fixer can get in a
# loop, which causes us to exit early.
'e501',
- 'w503'
]
key = pep8_result['id'].lower()
try:
@@ -2906,7 +2971,7 @@
"""Return True if syntax is okay."""
try:
return compile(code, '<string>', 'exec', dont_inherit=True)
- except (SyntaxError, TypeError, UnicodeDecodeError):
+ except (SyntaxError, TypeError, ValueError):
return False
@@ -3712,7 +3777,7 @@
def standard_deviation(numbers):
- """Return standard devation."""
+ """Return standard deviation."""
numbers = list(numbers)
if not numbers:
return 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/setup.py new/autopep8-1.4/setup.py
--- old/autopep8-1.3.5/setup.py 2018-03-30 06:25:19.000000000 +0200
+++ new/autopep8-1.4/setup.py 2018-09-01 18:00:07.000000000 +0200
@@ -46,6 +46,7 @@
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Quality Assurance',
],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autopep8-1.3.5/test/test_autopep8.py new/autopep8-1.4/test/test_autopep8.py
--- old/autopep8-1.3.5/test/test_autopep8.py 2018-03-30 07:17:19.000000000 +0200
+++ new/autopep8-1.4/test/test_autopep8.py 2018-09-01 17:05:18.000000000 +0200
@@ -58,6 +58,10 @@
maxDiff = None
+ def test_compile_value_error(self):
+ source = '"\\xhh" \\'
+ self.assertFalse(autopep8.check_syntax(source))
+
def test_find_newline_only_cr(self):
source = ['print 1\r', 'print 2\r', 'print3\r']
self.assertEqual(autopep8.CR, autopep8.find_newline(source))
@@ -564,6 +568,7 @@
self.assertEqual(' #\nif True:\n pass\n',
reindenter.run())
+ @unittest.skipIf('AUTOPEP8_COVERAGE' in os.environ, 'exists form-feed')
def test_reindenter_not_affect_with_formfeed(self):
lines = """print('hello')
@@ -1166,20 +1171,27 @@
with autopep8_context(line) as result:
self.assertEqual(line, result)
- def test_e113_should_not_modify_string_content(self):
+ def test_e113(self):
line = """\
a = 1
b = 2
"""
+ fixed = """\
+a = 1
+b = 2
+"""
with autopep8_context(line) as result:
- self.assertEqual(line, result)
+ self.assertEqual(fixed, result)
- def test_e113_should_leave_bad_syntax_alone(self):
+ def test_e113_bad_syntax(self):
line = """\
pass
"""
+ fixed = """\
+pass
+"""
with autopep8_context(line) as result:
- self.assertEqual(line, result)
+ self.assertEqual(fixed, result)
def test_e114(self):
line = """\
@@ -1541,6 +1553,20 @@
with autopep8_context(line, options=['--select=E12']) as result:
self.assertEqual(fixed, result)
+ def test_e128_with_aaa_option(self):
+ line = """\
+def extractBlocks(self):
+ addLine = (self.matchMultiple(linesIncludePatterns, line)
+ and not self.matchMultiple(linesExcludePatterns, line)) or emptyLine
+"""
+ fixed = """\
+def extractBlocks(self):
+ addLine = (self.matchMultiple(linesIncludePatterns, line) and
+ not self.matchMultiple(linesExcludePatterns, line)) or emptyLine
+"""
+ with autopep8_context(line, options=['-aaa']) as result:
+ self.assertEqual(fixed, result)
+
def test_e129(self):
line = """\
if (a and
@@ -1961,13 +1987,13 @@
class Foo(object):
def bar(self):
- return self.elephant is not None
+ return self.elephant!='test'
"""
fixed = """\
class Foo(object):
def bar(self):
- return self.elephant is not None
+ return self.elephant != 'test'
"""
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
@@ -2079,6 +2105,24 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e252(self):
+ line = 'def a(arg1: int=1, arg2: int =1, arg3: int= 1):\n print arg\n'
+ fixed = 'def a(arg1: int = 1, arg2: int = 1, arg3: int = 1):\n print arg\n'
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
+ def test_e252_with_argument_on_next_line(self):
+ line = 'def a(arg: int\n=1):\n print arg\n'
+ fixed = 'def a(arg: int\n= 1):\n print arg\n'
+ with autopep8_context(line, options=['--select=E252']) as result:
+ self.assertEqual(fixed, result)
+
+ def test_e252_with_escaped_newline(self):
+ line = 'def a(arg: int\\\n=1):\n print arg\n'
+ fixed = 'def a(arg: int\\\n= 1):\n print arg\n'
+ with autopep8_context(line, options=['--select=E252']) as result:
+ self.assertEqual(fixed, result)
+
def test_e261(self):
line = "print 'a b '# comment\n"
fixed = "print 'a b ' # comment\n"
@@ -2282,6 +2326,27 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e303_with_e305(self):
+ line = """\
+def foo():
+ pass
+
+
+
+# comment (E303)
+a = 1 # (E305)
+"""
+ fixed = """\
+def foo():
+ pass
+
+
+# comment (E303)
+a = 1 # (E305)
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
def test_e304(self):
line = '@contextmanager\n\ndef f():\n print 1\n'
fixed = '@contextmanager\ndef f():\n print 1\n'
@@ -3749,8 +3814,8 @@
self.assertEqual(fixed, result)
def test_e702_with_triple_quote_and_indent(self):
- line = ' """\n hello\n """; 1\n'
- fixed = ' """\n hello\n """\n 1\n'
+ line = 'def f():\n """\n hello\n """; 1\n'
+ fixed = 'def f():\n """\n hello\n """\n 1\n'
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
@@ -3788,6 +3853,16 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e703_in_example_of_readme(self):
+ line = """\
+def example2(): return ('' in {'f': 2}) in {'has_key() is deprecated': True};
+"""
+ fixed = """\
+def example2(): return ('' in {'f': 2}) in {'has_key() is deprecated': True}
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
def test_e704(self):
line = 'def f(x): return 2*x\n'
fixed = 'def f(x):\n return 2 * x\n'
@@ -4071,6 +4146,12 @@
with autopep8_context(line, options=['--select=E731']) as result:
self.assertEqual(fixed, result)
+ def test_e731_with_default_arguments(self):
+ line = 'a = lambda k, d=None: bar.get("%s/%s" % (prefix, k), d)\n'
+ fixed = 'def a(k, d=None): return bar.get("%s/%s" % (prefix, k), d)\n'
+ with autopep8_context(line, options=['--select=E731']) as result:
+ self.assertEqual(fixed, result)
+
def test_e901_should_cause_indentation_screw_up(self):
line = """\
def tmp(g):
@@ -4223,6 +4304,32 @@
with autopep8_context(line, options=['-aaa']) as result:
self.assertEqual(fixed, result)
+ def test_w503_over_5lines(self):
+ line = """\
+X = (
+ 1 # 1
+ + 2 # 2
+ + 3 # 3
+ + 4 # 4
+ + 5 # 5
+ + 6 # 6
+ + 7 # 7
+)
+"""
+ fixed = """\
+X = (
+ 1 + # 1
+ 2 + # 2
+ 3 + # 3
+ 4 + # 4
+ 5 + # 5
+ 6 + # 6
+ 7 # 7
+)
+"""
+ with autopep8_context(line, options=['-aaa']) as result:
+ self.assertEqual(fixed, result)
+
def test_w601(self):
line = 'a = {0: 1}\na.has_key(0)\n'
fixed = 'a = {0: 1}\n0 in a\n'
@@ -4500,6 +4607,12 @@
with autopep8_context(line, options=['--aggressive']) as result:
self.assertEqual(fixed, result)
+ def test_w605_simple(self):
+ line = "escape = '\.jpg'\n"
+ fixed = "escape = r'\.jpg'\n"
+ with autopep8_context(line, options=['--aggressive']) as result:
+ self.assertEqual(fixed, result)
+
def test_trailing_whitespace_in_multiline_string(self):
line = 'x = """ \nhello""" \n'
fixed = 'x = """ \nhello"""\n'
@@ -5862,6 +5975,7 @@
def test_e501_experimental_no_line_change(self):
line = """\
+def f():
return '<a href="javascript:;" class="copy-to-clipboard-button" data-clipboard-text="%s" title="copy url to clipboard">Copy Link</a>' % url
"""
with autopep8_context(line, options=['--experimental']) as result: