Hello community,
here is the log from the commit of package python-pyupgrade for
openSUSE:Factory checked in at 2020-08-12 10:28:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pyupgrade (Old)
and /work/SRC/openSUSE:Factory/.python-pyupgrade.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyupgrade"
Wed Aug 12 10:28:21 2020 rev:2 rq:825393 version:2.7.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pyupgrade/python-pyupgrade.changes
2020-07-17 20:48:11.960754008 +0200
+++
/work/SRC/openSUSE:Factory/.python-pyupgrade.new.3399/python-pyupgrade.changes
2020-08-12 10:29:46.236024017 +0200
@@ -1,0 +2,8 @@
+Mon Aug 3 13:30:45 UTC 2020 - Marketa Calabkova <[email protected]>
+
+- update to 2.7.2
+ * fix any call with *sys.exc_info()
+ * leave f'string'.format(...) alone
+ * `reraise` and `raise_from` doc examples
+
+-------------------------------------------------------------------
Old:
----
python-pyupgrade-2.6.2.tar.gz
New:
----
python-pyupgrade-2.7.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pyupgrade.spec ++++++
--- /var/tmp/diff_new_pack.Cp0Hox/_old 2020-08-12 10:29:48.012025388 +0200
+++ /var/tmp/diff_new_pack.Cp0Hox/_new 2020-08-12 10:29:48.012025388 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pyupgrade
#
-# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,25 +12,26 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pyupgrade
-Version: 2.6.2
+Version: 2.7.2
Release: 0
-License: MIT
Summary: A tool to automatically upgrade syntax for newer versions
-Url: https://github.com/asottile/pyupgrade
+License: MIT
Group: Development/Languages/Python
-# pypi tarball does not include tests, use github instead. PR for inclusion:
https://github.com/asottile/pyupgrade/pull/326
+URL: https://github.com/asottile/pyupgrade
+# pypi tarball does not include tests, use github instead. PR for inclusion
was denied https://github.com/asottile/pyupgrade/pull/326
Source:
https://github.com/asottile/pyupgrade/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
#Source:
https://files.pythonhosted.org/packages/source/p/pyupgrade/pyupgrade-%%{version}.tar.gz
-BuildRequires: python-rpm-macros
BuildRequires: %{python_module setuptools}
+BuildRequires: python-rpm-macros
# SECTION test requirements
-BuildRequires: %{python_module tokenize-rt >= 3.2.0}
BuildRequires: %{python_module pytest}
+BuildRequires: %{python_module tokenize-rt >= 3.2.0}
# /SECTION
BuildRequires: fdupes
Requires: python-tokenize-rt >= 3.2.0
++++++ python-pyupgrade-2.6.2.tar.gz -> python-pyupgrade-2.7.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/.pre-commit-config.yaml
new/pyupgrade-2.7.2/.pre-commit-config.yaml
--- old/pyupgrade-2.6.2/.pre-commit-config.yaml 2020-06-25 08:01:34.000000000
+0200
+++ new/pyupgrade-2.7.2/.pre-commit-config.yaml 2020-07-24 17:28:26.000000000
+0200
@@ -34,7 +34,7 @@
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade
- rev: v2.6.2
+ rev: v2.7.2
hooks:
- id: pyupgrade
args: [--py36-plus]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/README.md
new/pyupgrade-2.7.2/README.md
--- old/pyupgrade-2.6.2/README.md 2020-06-25 08:01:34.000000000 +0200
+++ new/pyupgrade-2.7.2/README.md 2020-07-24 17:28:26.000000000 +0200
@@ -19,7 +19,7 @@
```yaml
- repo: https://github.com/asottile/pyupgrade
- rev: v2.6.2
+ rev: v2.7.2
hooks:
- id: pyupgrade
```
@@ -339,6 +339,9 @@
six.get_function_code(fn) # fn.__code__
six.get_function_defaults(fn) # fn.__defaults__
six.get_function_globals(fn) # fn.__globals__
+six.raise_from(exc, exc_from) # raise exc from exc_from
+six.reraise(tp, exc, tb) # raise exc.with_traceback(tb)
+six.reraise(*sys.exc_info()) # raise
six.assertCountEqual(self, a1, a2) # self.assertCountEqual(a1, a2)
six.assertRaisesRegex(self, e, r, fn) # self.assertRaisesRegex(e, r, fn)
six.assertRegex(self, s, r) # self.assertRegex(s, r)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/pyupgrade.py
new/pyupgrade-2.7.2/pyupgrade.py
--- old/pyupgrade-2.6.2/pyupgrade.py 2020-06-25 08:01:34.000000000 +0200
+++ new/pyupgrade-2.7.2/pyupgrade.py 2020-07-24 17:28:26.000000000 +0200
@@ -587,6 +587,11 @@
parsed_parts = []
last_int = -1
for i in parts:
+ # f'foo {0}'.format(...) would get turned into a SyntaxError
+ prefix, _ = parse_string_literal(tokens[i].src)
+ if 'f' in prefix.lower():
+ return
+
try:
parsed = parse_format(tokens[i].src)
except ValueError:
@@ -1121,6 +1126,7 @@
WITH_METACLASS_NO_BASES_TMPL = 'metaclass={args[0]}'
WITH_METACLASS_BASES_TMPL = '{rest}, metaclass={args[0]}'
RAISE_FROM_TMPL = 'raise {args[0]} from {rest}'
+RERAISE_TMPL = 'raise'
RERAISE_2_TMPL = 'raise {args[1]}.with_traceback(None)'
RERAISE_3_TMPL = 'raise {args[1]}.with_traceback({args[2]})'
SIX_NATIVE_STR = frozenset(('ensure_str', 'ensure_text', 'text_type'))
@@ -1216,6 +1222,7 @@
self.encode_calls: Dict[Offset, ast.Call] = {}
+ self._exc_info_imported = False
self._version_info_imported = False
self.if_py3_blocks: Set[Offset] = set()
self.if_py2_blocks_else: Set[Offset] = set()
@@ -1267,6 +1274,14 @@
node.attr in names
)
+ def _is_star_sys_exc_info(self, node: ast.Call) -> bool:
+ return (
+ len(node.args) == 1 and
+ isinstance(node.args[0], ast.Starred) and
+ isinstance(node.args[0].value, ast.Call) and
+ self._is_exc_info(node.args[0].value.func)
+ )
+
def _is_lru_cache(self, node: ast.expr) -> bool:
return (
isinstance(node, ast.Name) and
@@ -1314,6 +1329,18 @@
node.attr == 'error'
)
+ def _is_exc_info(self, node: ast.expr) -> bool:
+ return (
+ isinstance(node, ast.Name) and
+ node.id == 'exc_info' and
+ self._exc_info_imported
+ ) or (
+ isinstance(node, ast.Attribute) and
+ isinstance(node.value, ast.Name) and
+ node.value.id == 'sys' and
+ node.attr == 'exc_info'
+ )
+
def _is_version_info(self, node: ast.expr) -> bool:
return (
isinstance(node, ast.Name) and
@@ -1335,6 +1362,11 @@
elif self._find_mock and node.module in self.MOCK_MODULES:
self.mock_relative_imports.add(_ast_to_offset(node))
elif node.module == 'sys' and any(
+ name.name == 'exc_info' and not name.asname
+ for name in node.names
+ ):
+ self._exc_info_imported = True
+ elif node.module == 'sys' and any(
name.name == 'version_info' and not name.asname
for name in node.names
):
@@ -1526,7 +1558,7 @@
elif (
isinstance(self._previous_node, ast.Expr) and
self._is_six(node.func, ('reraise',)) and
- not _starargs(node)
+ (not _starargs(node) or self._is_star_sys_exc_info(node))
):
self.six_reraise.add(_ast_to_offset(node))
elif (
@@ -2143,10 +2175,13 @@
elif token.offset in visitor.six_reraise:
j = _find_open_paren(tokens, i)
func_args, end = _parse_call_args(tokens, j)
- if len(func_args) == 2:
- _replace_call(tokens, i, end, func_args, RERAISE_2_TMPL)
+ if len(func_args) == 1:
+ tmpl = RERAISE_TMPL
+ elif len(func_args) == 2:
+ tmpl = RERAISE_2_TMPL
else:
- _replace_call(tokens, i, end, func_args, RERAISE_3_TMPL)
+ tmpl = RERAISE_3_TMPL
+ _replace_call(tokens, i, end, func_args, tmpl)
elif token.offset in visitor.six_add_metaclass:
j = _find_open_paren(tokens, i)
func_args, end = _parse_call_args(tokens, j)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/setup.cfg
new/pyupgrade-2.7.2/setup.cfg
--- old/pyupgrade-2.6.2/setup.cfg 2020-06-25 08:01:34.000000000 +0200
+++ new/pyupgrade-2.7.2/setup.cfg 2020-07-24 17:28:26.000000000 +0200
@@ -1,6 +1,6 @@
[metadata]
name = pyupgrade
-version = 2.6.2
+version = 2.7.2
description = A tool to automatically upgrade syntax for newer versions.
long_description = file: README.md
long_description_content_type = text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/tests/format_literals_test.py
new/pyupgrade-2.7.2/tests/format_literals_test.py
--- old/pyupgrade-2.6.2/tests/format_literals_test.py 2020-06-25
08:01:34.000000000 +0200
+++ new/pyupgrade-2.7.2/tests/format_literals_test.py 2020-07-24
17:28:26.000000000 +0200
@@ -51,6 +51,8 @@
'("{0}" # {1}\n"{2}").format(1, 2, 3)',
# TODO: this works by accident (extended escape treated as placeholder)
r'"\N{snowman} {}".format(1)',
+ # don't touch f-strings (these are wrong but don't make it worse)
+ 'f"{0}".format(a)',
),
)
def test_format_literals_noop(s):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pyupgrade-2.6.2/tests/six_test.py
new/pyupgrade-2.7.2/tests/six_test.py
--- old/pyupgrade-2.6.2/tests/six_test.py 2020-06-25 08:01:34.000000000
+0200
+++ new/pyupgrade-2.7.2/tests/six_test.py 2020-07-24 17:28:26.000000000
+0200
@@ -41,6 +41,7 @@
'isinstance("foo", text_type)\n',
id='relative import might not be six',
),
+ ('traceback.format_exc(*sys.exc_info())'),
),
)
def test_fix_six_noop(s):
@@ -225,6 +226,17 @@
'raise exc.with_traceback(None)\n',
),
(
+ 'six.reraise(*sys.exc_info())\n',
+ 'raise\n',
+ ),
+ (
+ 'from sys import exc_info\n'
+ 'six.reraise(*exc_info())\n',
+
+ 'from sys import exc_info\n'
+ 'raise\n',
+ ),
+ (
'from six import raise_from\n'
'raise_from(exc, exc_from)\n',