Hello community,

here is the log from the commit of package python-autopep8 for openSUSE:Factory 
checked in at 2020-06-10 00:49:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-autopep8 (Old)
 and      /work/SRC/openSUSE:Factory/.python-autopep8.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-autopep8"

Wed Jun 10 00:49:05 2020 rev:19 rq:812802 version:1.5.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-autopep8/python-autopep8.changes  
2020-04-25 20:36:41.763057851 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-autopep8.new.3606/python-autopep8.changes    
    2020-06-10 00:49:08.787059615 +0200
@@ -1,0 +2,9 @@
+Tue Jun  9 07:39:23 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 1.5.3:
+  * requirement pycodestyle version 2.6.0+ ( #548 )
+  * Expected pyproject.toml configuration syntax incompatible with TOML format 
( #528 , #546 )
+  * Fix incompatible exit code with --jobs=0 and --exit-code ( #543 , #545 )
+  * Fix hangup E122 fixed method with backslash ( #540 , #541 )
+
+-------------------------------------------------------------------

Old:
----
  autopep8-1.5.2.tar.gz

New:
----
  autopep8-1.5.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-autopep8.spec ++++++
--- /var/tmp/diff_new_pack.7YqFZU/_old  2020-06-10 00:49:09.475061414 +0200
+++ /var/tmp/diff_new_pack.7YqFZU/_new  2020-06-10 00:49:09.475061414 +0200
@@ -18,18 +18,20 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-autopep8
-Version:        1.5.2
+Version:        1.5.3
 Release:        0
 Summary:        Automatic generated to pep8 checked code
 License:        MIT
 Group:          Development/Languages/Python
 URL:            https://github.com/hhatto/autopep8
 Source:         
https://files.pythonhosted.org/packages/source/a/autopep8/autopep8-%{version}.tar.gz
-BuildRequires:  %{python_module pycodestyle >= 2.4}
+BuildRequires:  %{python_module pycodestyle >= 2.6}
 BuildRequires:  %{python_module setuptools}
+BuildRequires:  %{python_module toml}
 BuildRequires:  python-rpm-macros
-Requires:       python-pycodestyle >= 2.4
+Requires:       python-pycodestyle >= 2.6
 Requires:       python-setuptools
+Requires:       python-toml
 Requires(post): update-alternatives
 Requires(postun): update-alternatives
 BuildArch:      noarch

++++++ autopep8-1.5.2.tar.gz -> autopep8-1.5.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/PKG-INFO new/autopep8-1.5.3/PKG-INFO
--- old/autopep8-1.5.2/PKG-INFO 2020-04-20 13:59:18.000000000 +0200
+++ new/autopep8-1.5.3/PKG-INFO 2020-05-31 16:15:33.755008500 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: autopep8
-Version: 1.5.2
+Version: 1.5.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
@@ -379,7 +379,7 @@
         
             [tool.autopep8]
             max_line_length = 120
-            ignore = E501
+            ignore = "E501,W6"  # or ["E501", "W6"]
         
         
         Testing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/README.rst 
new/autopep8-1.5.3/README.rst
--- old/autopep8-1.5.2/README.rst       2020-04-09 03:23:43.000000000 +0200
+++ new/autopep8-1.5.3/README.rst       2020-05-31 15:08:01.000000000 +0200
@@ -371,7 +371,7 @@
 
     [tool.autopep8]
     max_line_length = 120
-    ignore = E501
+    ignore = "E501,W6"  # or ["E501", "W6"]
 
 
 Testing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/autopep8.egg-info/PKG-INFO 
new/autopep8-1.5.3/autopep8.egg-info/PKG-INFO
--- old/autopep8-1.5.2/autopep8.egg-info/PKG-INFO       2020-04-20 
13:59:18.000000000 +0200
+++ new/autopep8-1.5.3/autopep8.egg-info/PKG-INFO       2020-05-31 
16:15:33.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: autopep8
-Version: 1.5.2
+Version: 1.5.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
@@ -379,7 +379,7 @@
         
             [tool.autopep8]
             max_line_length = 120
-            ignore = E501
+            ignore = "E501,W6"  # or ["E501", "W6"]
         
         
         Testing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/autopep8.egg-info/requires.txt 
new/autopep8-1.5.3/autopep8.egg-info/requires.txt
--- old/autopep8-1.5.2/autopep8.egg-info/requires.txt   2020-04-20 
13:59:18.000000000 +0200
+++ new/autopep8-1.5.3/autopep8.egg-info/requires.txt   2020-05-31 
16:15:33.000000000 +0200
@@ -1 +1,2 @@
-pycodestyle>=2.5.0
+pycodestyle>=2.6.0
+toml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/autopep8.py 
new/autopep8-1.5.3/autopep8.py
--- old/autopep8-1.5.2/autopep8.py      2020-04-20 13:58:30.000000000 +0200
+++ new/autopep8-1.5.3/autopep8.py      2020-05-31 16:00:34.000000000 +0200
@@ -66,6 +66,7 @@
     from ConfigParser import SafeConfigParser
     from ConfigParser import Error
 
+import toml
 import pycodestyle
 from pycodestyle import STARTSWITH_INDENT_STATEMENT_REGEX
 
@@ -76,7 +77,7 @@
     unicode = str
 
 
-__version__ = '1.5.2'
+__version__ = '1.5.3'
 
 
 CR = '\r'
@@ -819,8 +820,13 @@
     def fix_e302(self, result):
         """Add missing 2 blank lines."""
         add_linenum = 2 - int(result['info'].split()[-1])
+        offset = 1
+        if self.source[result['line'] - 2].strip() == "\\":
+            offset = 2
         cr = '\n' * add_linenum
-        self.source[result['line'] - 1] = cr + self.source[result['line'] - 1]
+        self.source[result['line'] - offset] = (
+            cr + self.source[result['line'] - offset]
+        )
 
     def fix_e303(self, result):
         """Remove extra blank lines."""
@@ -3751,7 +3757,10 @@
     if apply_config:
         parser = read_config(args, parser)
         # prioritize settings when exist pyproject.toml's tool.autopep8 section
-        parser_with_pyproject_toml = read_pyproject_toml(args, parser)
+        try:
+            parser_with_pyproject_toml = read_pyproject_toml(args, parser)
+        except Exception:
+            parser_with_pyproject_toml = None
         if parser_with_pyproject_toml:
             parser = parser_with_pyproject_toml
         args = parser.parse_args(arguments)
@@ -3886,39 +3895,53 @@
 
 def read_pyproject_toml(args, parser):
     """Read pyproject.toml and load configuration."""
-    config = SafeConfigParser()
+    config = None
 
-    try:
-        config.read(args.global_config)
-
-        if not args.ignore_local_config:
-            parent = tail = args.files and os.path.abspath(
-                os.path.commonprefix(args.files))
-            while tail:
-                if config.read([os.path.join(parent, "pyproject.toml"), ]):
+    if os.path.exists(args.global_config):
+        with open(args.global_config) as fp:
+            config = toml.load(fp)
+
+    if not args.ignore_local_config:
+        parent = tail = args.files and os.path.abspath(
+            os.path.commonprefix(args.files))
+        while tail:
+            pyproject_toml = os.path.join(parent, "pyproject.toml")
+            if os.path.exists(pyproject_toml):
+                with open(pyproject_toml) as fp:
+                    config = toml.load(fp)
                     break
-                (parent, tail) = os.path.split(parent)
-
-        defaults = {}
-        option_list = {o.dest: o.type or type(o.default)
-                       for o in parser._actions}
+            (parent, tail) = os.path.split(parent)
 
-        for section in ["tool.autopep8"]:
-            if not config.has_section(section):
-                continue
-            for norm_opt, k, value in _get_normalize_options(config, section,
-                                                             option_list):
-                if args.verbose:
-                    print("enable pyproject.toml config: section={}, "
-                          "key={}, value={}".format(section, k, value))
-                defaults[norm_opt] = value
+    if not config:
+        return None
 
-        if defaults:
-            # set value when exists key-value in defaults dict
-            parser.set_defaults(**defaults)
-    except Error:
+    if config.get("tool", {}).get("autopep8") is None:
         return None
 
+    config = config.get("tool").get("autopep8")
+
+    defaults = {}
+    option_list = {o.dest: o.type or type(o.default)
+                   for o in parser._actions}
+
+    TUPLED_OPTIONS = ("ignore", "select")
+    for (k, v) in config.items():
+        norm_opt = k.lstrip('-').replace('-', '_')
+        if not option_list.get(norm_opt):
+            continue
+        if type(v) in (list, tuple) and norm_opt in TUPLED_OPTIONS:
+            value = ",".join(v)
+        else:
+            value = v
+        if args.verbose:
+            print("enable pyproject.toml config: "
+                  "key={}, value={}".format(k, value))
+        defaults[norm_opt] = value
+
+    if defaults:
+        # set value when exists key-value in defaults dict
+        parser.set_defaults(**defaults)
+
     return parser
 
 
@@ -4358,7 +4381,12 @@
                 assert len(args.files) == 1
                 assert not args.recursive
 
-            ret = fix_multiple_files(args.files, args, sys.stdout)
+            results = fix_multiple_files(args.files, args, sys.stdout)
+            if args.diff:
+                ret = any([len(ret) != 0 for ret in results])
+            else:
+                # with in-place option
+                ret = any([ret is not None for ret in results])
             if args.exit_code and ret:
                 return EXIT_CODE_EXISTS_DIFF
     except KeyboardInterrupt:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/setup.py new/autopep8-1.5.3/setup.py
--- old/autopep8-1.5.2/setup.py 2020-04-09 03:23:43.000000000 +0200
+++ new/autopep8-1.5.3/setup.py 2020-05-31 16:00:11.000000000 +0200
@@ -10,7 +10,7 @@
 
 
 INSTALL_REQUIRES = (
-    ['pycodestyle >= 2.5.0']
+    ['pycodestyle >= 2.6.0', 'toml']
 )
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autopep8-1.5.2/test/test_autopep8.py 
new/autopep8-1.5.3/test/test_autopep8.py
--- old/autopep8-1.5.2/test/test_autopep8.py    2020-04-20 13:58:18.000000000 
+0200
+++ new/autopep8-1.5.3/test/test_autopep8.py    2020-05-31 16:00:11.000000000 
+0200
@@ -15,7 +15,7 @@
 import os
 import re
 import sys
-
+import time
 import contextlib
 import io
 import shutil
@@ -3646,8 +3646,6 @@
     pass
 """
         fixed = """\
-
-
 def foobar(
         sldfkjlsdfsdf,
         kksdfsdfsf,
@@ -5161,6 +5159,22 @@
         with autopep8_context(line) as result:
             self.assertEqual(result[:4], 'from')
 
+    @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_with_walrus_operator(self):
+        """check pycodestyle 2.6.0+"""
+        line = """\
+sql_stmt = ""
+with open(filename) as f:
+    while line := f.readline():
+        sql_stmt += line
+"""
+        with autopep8_context(line) as result:
+            self.assertEqual(line, result)
+
 
 class UtilityFunctionTests(unittest.TestCase):
 
@@ -5205,6 +5219,25 @@
 
     maxDiff = None
 
+    def test_e122_and_e302_with_backslash(self):
+        line = """\
+import sys
+\\
+def f():
+    pass
+"""
+        fixed = """\
+import sys
+
+
+\\
+def f():
+    pass
+"""
+        with autopep8_subprocess(line, [], timeout=3) as (result, retcode):
+            self.assertEqual(fixed, result)
+            self.assertEqual(retcode, autopep8.EXIT_CODE_OK)
+
     def test_diff(self):
         line = "'abc'  \n"
         fixed = "-'abc'  \n+'abc'\n"
@@ -5225,6 +5258,12 @@
             self.assertEqual('', '\n'.join(result.split('\n')[3:]))
             self.assertEqual(retcode, autopep8.EXIT_CODE_OK)
 
+    def test_non_diff_with_exit_code_and_jobs_options(self):
+        line = "'abc'\n"
+        with autopep8_subprocess(line, ['-j0', '--diff', '--exit-code']) as 
(result, retcode):
+            self.assertEqual('', '\n'.join(result.split('\n')[3:]))
+            self.assertEqual(retcode, autopep8.EXIT_CODE_OK)
+
     def test_diff_with_empty_file(self):
         with autopep8_subprocess('', ['--diff']) as (result, retcode):
             self.assertEqual('\n'.join(result.split('\n')[3:]), '')
@@ -5726,7 +5765,7 @@
         """override to flake8 config"""
         line = "a =  1\n"
         dot_flake8 = """[pep8]\naggressive=0\n"""
-        pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore=E,W\n"""
+        pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore="E,W"\n"""
         with temporary_project_directory() as dirname:
             with open(os.path.join(dirname, "pyproject.toml"), "w") as fp:
                 fp.write(pyproject_toml)
@@ -5742,8 +5781,8 @@
     def test_pyproject_toml_with_verbose_option(self):
         """override to flake8 config"""
         line = "a =  1\n"
-        verbose_line = "enable pyproject.toml config: section=tool.autopep8, 
key=ignore, value=E,W\n"
-        pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore=E,W\n"""
+        verbose_line = "enable pyproject.toml config: key=ignore, value=E,W\n"
+        pyproject_toml = """[tool.autopep8]\naggressvie=2\nignore="E,W"\n"""
         with temporary_project_directory() as dirname:
             with open(os.path.join(dirname, "pyproject.toml"), "w") as fp:
                 fp.write(pyproject_toml)
@@ -5756,6 +5795,20 @@
             self.assertTrue(verbose_line in output)
             self.assertEqual(p.returncode, 0)
 
+    def test_pyproject_toml_with_iterable_value(self):
+        line = "a =  1\n"
+        pyproject_toml = 
"""[tool.autopep8]\naggressvie=2\nignore=["E","W"]\n"""
+        with temporary_project_directory() as dirname:
+            with open(os.path.join(dirname, "pyproject.toml"), "w") as fp:
+                fp.write(pyproject_toml)
+            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)
+            output = p.communicate()[0].decode("utf-8")
+            self.assertTrue(line in output)
+            self.assertEqual(p.returncode, 0)
+
 
 class ExperimentalSystemTests(unittest.TestCase):
 
@@ -6247,7 +6300,7 @@
 class Useless(object):
 
     def _table_field_is_plain_widget(self, widget):
-        if widget.__class__ == Widget or(
+        if widget.__class__ == Widget or (
                 widget.__class__ == WidgetMeta and Widget in widget.__bases__):
             return True
 
@@ -6642,8 +6695,6 @@
 @foo(('xxxxxxxxxxxxxxxxxxxxxxxxxx', users.xxxxxxxxxxxxxxxxxxxxxxxxxx), 
('yyyyyyyyyyyy', users.yyyyyyyyyyyy), ('zzzzzzzzzzzzzz', users.zzzzzzzzzzzzzz))
 """
         fixed = """\
-
-
 @foo(('xxxxxxxxxxxxxxxxxxxxxxxxxx', users.xxxxxxxxxxxxxxxxxxxxxxxxxx),
      ('yyyyyyyyyyyy', users.yyyyyyyyyyyy),
      ('zzzzzzzzzzzzzz', users.zzzzzzzzzzzzzz))
@@ -7036,11 +7087,24 @@
 
 
 @contextlib.contextmanager
-def autopep8_subprocess(line, options):
+def autopep8_subprocess(line, options, timeout=None):
     with temporary_file_context(line) as filename:
-        p = Popen(list(AUTOPEP8_CMD_TUPLE) + [filename] + options,
-                  stdout=PIPE)
-        yield (p.communicate()[0].decode('utf-8'), p.returncode)
+        p = Popen(list(AUTOPEP8_CMD_TUPLE) + [filename] + options, stdout=PIPE)
+        if timeout is None:
+            _stdout, _ = p.communicate()
+        else:
+            try:
+                _stdout, _ = p.communicate(timeout=timeout)
+            except TypeError:
+                # for Python2
+                while p.poll() is None and timeout > 0:
+                    time.sleep(0.5)
+                    timeout -= 0.5
+                if p.poll() is None:
+                    p.kill()
+                    raise Exception("subprocess is timed out")
+                _stdout, _ = p.communicate()
+        yield (_stdout.decode('utf-8'), p.returncode)
 
 
 @contextlib.contextmanager


Reply via email to