Hello community,
here is the log from the commit of package python-autopep8 for openSUSE:Factory
checked in at 2018-11-26 10:29:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old)
and /work/SRC/openSUSE:Factory/.python-autopep8.new.19453 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-autopep8"
Mon Nov 26 10:29:42 2018 rev:15 rq:651333 version:1.4.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes
2018-10-31 13:20:56.183085652 +0100
+++
/work/SRC/openSUSE:Factory/.python-autopep8.new.19453/python-autopep8.changes
2018-11-26 10:29:56.849053228 +0100
@@ -1,0 +2,10 @@
+Thu Nov 22 22:35:26 UTC 2018 - Arun Persaud <[email protected]>
+
+- update to version 1.4.3:
+ * w605 fixes for identical tokens
+ * fix e402 fixed method when import some modules (for #447)
+ * use _is_binary_operator
+ * (origin/fix-w503-more-corner-cases) fix w503 with comment into
+ pointed out line (for #446)
+
+-------------------------------------------------------------------
Old:
----
autopep8-1.4.2.tar.gz
New:
----
autopep8-1.4.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-autopep8.spec ++++++
--- /var/tmp/diff_new_pack.5tEjiQ/_old 2018-11-26 10:29:57.745052178 +0100
+++ /var/tmp/diff_new_pack.5tEjiQ/_new 2018-11-26 10:29:57.749052173 +0100
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-autopep8
-Version: 1.4.2
+Version: 1.4.3
Release: 0
Summary: Automatic generated to pep8 checked code
License: MIT
++++++ autopep8-1.4.2.tar.gz -> autopep8-1.4.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.2/PKG-INFO new/autopep8-1.4.3/PKG-INFO
--- old/autopep8-1.4.2/PKG-INFO 2018-10-23 17:09:34.000000000 +0200
+++ new/autopep8-1.4.3/PKG-INFO 2018-11-12 14:55:55.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.4.2
+Version: 1.4.3
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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.2/autopep8.egg-info/PKG-INFO
new/autopep8-1.4.3/autopep8.egg-info/PKG-INFO
--- old/autopep8-1.4.2/autopep8.egg-info/PKG-INFO 2018-10-23
17:09:34.000000000 +0200
+++ new/autopep8-1.4.3/autopep8.egg-info/PKG-INFO 2018-11-12
14:55:54.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: autopep8
-Version: 1.4.2
+Version: 1.4.3
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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.2/autopep8.py
new/autopep8-1.4.3/autopep8.py
--- old/autopep8-1.4.2/autopep8.py 2018-10-23 17:09:21.000000000 +0200
+++ new/autopep8-1.4.3/autopep8.py 2018-11-12 14:54:44.000000000 +0100
@@ -67,7 +67,7 @@
unicode = str
-__version__ = '1.4.2'
+__version__ = '1.4.3'
CR = '\r'
@@ -873,11 +873,19 @@
def fix_e402(self, result):
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
+ for i in range(1, 100):
+ line = "".join(self.source[line_index:line_index+i])
+ try:
+ generate_tokens("".join(line))
+ except (SyntaxError, tokenize.TokenError):
+ continue
+ break
if not (target in self.imports and self.imports[target] != line_index):
mod_offset = get_module_imports_on_top_of_file(self.source,
line_index)
- self.source[mod_offset] = target + self.source[mod_offset]
- self.source[line_index] = ''
+ self.source[mod_offset] = line + self.source[mod_offset]
+ for offset in range(i):
+ self.source[line_index+offset] = ''
def fix_long_line_logically(self, result, logical):
"""Try to make lines fit within --max-line-length characters."""
@@ -1251,6 +1259,10 @@
tts = ts
old = None
for t in tts:
+ if t[0] in (tokenize.NEWLINE, tokenize.NL):
+ newline_count -= 1
+ if newline_count <= 1:
+ break
if tokenize.COMMENT == t[0] and old and old[0] != tokenize.NL:
comment_index = old[3][1]
break
@@ -1286,7 +1298,7 @@
newline_count = 0
newline_index = []
for index, t in enumerate(ts):
- if t[0] == tokenize.OP and t[1] not in ".,(){}":
+ if _is_binary_operator(t[0], t[1]):
if t[2][0] == 1 and t[3][0] == 1:
operator_position = (t[2][1], t[3][1])
elif t[0] == tokenize.NAME and t[1] in ("and", "or"):
@@ -1351,7 +1363,7 @@
'N', 'u', 'U',
]
- for token_type, text, start, end, line in tokens:
+ 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)
@@ -1366,7 +1378,8 @@
pos += 1
if string[pos] not in valid:
yield (
- line.find(text),
+ # No need to search line, token stores position
+ start_pos[1],
"W605 invalid escape sequence '\\%s'" %
string[pos],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/autopep8-1.4.2/test/test_autopep8.py
new/autopep8-1.4.3/test/test_autopep8.py
--- old/autopep8-1.4.2/test/test_autopep8.py 2018-10-23 17:09:21.000000000
+0200
+++ new/autopep8-1.4.3/test/test_autopep8.py 2018-11-12 14:53:41.000000000
+0100
@@ -2416,6 +2416,29 @@
with autopep8_context(line) as result:
self.assertEqual(fixed, result)
+ def test_e402_import_some_modules(self):
+ line = """\
+a = 1
+from csv import (
+ reader,
+ writer,
+)
+import os
+print(os, reader, writer)
+import os
+"""
+ fixed = """\
+import os
+from csv import (
+ reader,
+ writer,
+)
+a = 1
+print(os, reader, writer)
+"""
+ with autopep8_context(line) as result:
+ self.assertEqual(fixed, result)
+
def test_e501_basic(self):
line = """\
@@ -4302,6 +4325,24 @@
with autopep8_context(line, options=['--select=W503']) as result:
self.assertEqual(fixed, result)
+ def test_w503_with_comment_into_point_out_line(self):
+ line = """\
+def test():
+ return (
+ True not in []
+ and False # comment required
+ )
+"""
+ fixed = """\
+def test():
+ return (
+ True not in [] and
+ False # comment required
+ )
+"""
+ with autopep8_context(line, options=['--select=W503']) as result:
+ self.assertEqual(fixed, result)
+
def test_w503_with_comment_double(self):
line = """\
(
@@ -4693,6 +4734,25 @@
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
+ # the old, failing code. DO NOT REMOVE.
+ line = "escape = foo('\.bar', '\.kilroy')\n"
+ fixed = "escape = foo(r'\.bar', r'\.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"
+ 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"
+ with autopep8_context(line, options=['--aggressive', '--pep8-passes',
'5']) as result:
+ self.assertEqual(fixed, result)
+
def test_trailing_whitespace_in_multiline_string(self):
line = 'x = """ \nhello""" \n'
fixed = 'x = """ \nhello"""\n'