Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-pyupgrade for 
openSUSE:Factory checked in at 2021-06-02 22:11:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pyupgrade (Old)
 and      /work/SRC/openSUSE:Factory/.python-pyupgrade.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pyupgrade"

Wed Jun  2 22:11:23 2021 rev:11 rq:896594 version:2.18.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pyupgrade/python-pyupgrade.changes        
2021-05-16 23:44:15.609105466 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pyupgrade.new.1898/python-pyupgrade.changes  
    2021-06-02 22:11:43.292136018 +0200
@@ -1,0 +2,32 @@
+Tue May 25 07:46:49 UTC 2021 - Sebastian Wagner <[email protected]>
+
+- update to versio 2.18.3:
+ - remove trailing comma after removed list comp
+
+-------------------------------------------------------------------
+Mon May 24 17:12:55 UTC 2021 - Sebastian Wagner <[email protected]>
+
+- update to version 2.18.2:
+ -  don't rewrite list comp to generator expression in short-circuiting 
functions
+
+-------------------------------------------------------------------
+Fri May 21 16:01:15 UTC 2021 - Sebastian Wagner <[email protected]>
+
+- update to version 2.18.1:
+ - check argument count for generator rewrite
+- update to version 2.18.0:
+ - use generator expressions in single arg func calls
+
+-------------------------------------------------------------------
+Wed May 19 07:23:18 UTC 2021 - Sebastian Wagner <[email protected]>
+
+- update to version 2.17.0:
+ - Fix typo in the "is" example of README
+ - use generator to unpack list comprehension
+- update to version 2.16.0:
+ - don't crash on --py311-plus
+ - Use more inclusive language
+ - pep584-rewrite
+ - note pep584 change in README
+
+-------------------------------------------------------------------

Old:
----
  python-pyupgrade-2.15.0.tar.gz

New:
----
  python-pyupgrade-2.18.3.tar.gz

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

Other differences:
------------------
++++++ python-pyupgrade.spec ++++++
--- /var/tmp/diff_new_pack.nfCP77/_old  2021-06-02 22:11:43.768136802 +0200
+++ /var/tmp/diff_new_pack.nfCP77/_new  2021-06-02 22:11:43.772136809 +0200
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-pyupgrade
-Version:        2.15.0
+Version:        2.18.3
 Release:        0
 Summary:        A tool to automatically upgrade syntax for newer versions
 License:        MIT

++++++ python-pyupgrade-2.15.0.tar.gz -> python-pyupgrade-2.18.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/.pre-commit-config.yaml 
new/pyupgrade-2.18.3/.pre-commit-config.yaml
--- old/pyupgrade-2.15.0/.pre-commit-config.yaml        2021-05-08 
23:13:59.000000000 +0200
+++ new/pyupgrade-2.18.3/.pre-commit-config.yaml        2021-05-25 
04:35:17.000000000 +0200
@@ -1,6 +1,6 @@
 repos:
 -   repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v3.4.0
+    rev: v4.0.1
     hooks:
     -   id: check-docstring-first
     -   id: check-yaml
@@ -15,7 +15,7 @@
     hooks:
     -   id: setup-cfg-fmt
 -   repo: https://github.com/PyCQA/flake8
-    rev: 3.9.1
+    rev: 3.9.2
     hooks:
     -   id: flake8
         additional_dependencies: [flake8-typing-imports==1.7.0]
@@ -34,7 +34,7 @@
     -   id: add-trailing-comma
         args: [--py36-plus]
 -   repo: https://github.com/asottile/pyupgrade
-    rev: v2.15.0
+    rev: v2.18.3
     hooks:
     -   id: pyupgrade
         args: [--py36-plus]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/README.md 
new/pyupgrade-2.18.3/README.md
--- old/pyupgrade-2.15.0/README.md      2021-05-08 23:13:59.000000000 +0200
+++ new/pyupgrade-2.18.3/README.md      2021-05-25 04:35:17.000000000 +0200
@@ -20,7 +20,7 @@
 
 ```yaml
 -   repo: https://github.com/asottile/pyupgrade
-    rev: v2.15.0
+    rev: v2.18.3
     hooks:
     -   id: pyupgrade
 ```
@@ -46,6 +46,16 @@
 dict([(a, b) for a, b in y])  # {a: b for a, b in y}
 ```
 
+
+### Generator expressions for some built-in functions (pep 289)
+
+```python
+min([i for i in range(3)])  # min(i for i in range(3))
+max([i for i in range(3)])  # max(i for i in range(3))
+sum([i for i in range(3)])  # sum(i for i in range(3))
+''.join([str(i) for i in range(3)])  # ''.join(str(i) for i in range(3))
+```
+
 ### Python2.7+ Format Specifiers
 
 ```python
@@ -102,7 +112,7 @@
 ```python
 x is 5      # x == 5
 x is not 5  # x != 5
-x is 'foo'  # x == foo
+x is 'foo'  # x == 'foo'
 ```
 
 ### `ur` string literals
@@ -418,6 +428,18 @@
      ...
 ```
 
+
+### Unpacking list comprehensions
+
+Availability:
+- `--py3-plus` is passed on the commandline.
+
+```diff
+-foo, bar, baz = [fn(x) for x in items]
++foo, bar, baz = (fn(x) for x in items)
+```
+
+
 ### `typing.NamedTuple` / `typing.TypedDict` py36+ syntax
 
 Availability:
@@ -515,6 +537,19 @@
 ```
 
 
+### merge dicts using union operator (pep 584)
+
+Availability:
+- `--py39-plus` is passed on the commandline.
+
+```diff
+ x = {"a": 1}
+ y = {"b": 2}
+-z = {**x, **y}
++z = x | y
+```
+
+
 ### pep 585 typing rewrites
 
 Availability:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/pyupgrade/_main.py 
new/pyupgrade-2.18.3/pyupgrade/_main.py
--- old/pyupgrade-2.15.0/pyupgrade/_main.py     2021-05-08 23:13:59.000000000 
+0200
+++ new/pyupgrade-2.18.3/pyupgrade/_main.py     2021-05-25 04:35:17.000000000 
+0200
@@ -391,6 +391,7 @@
         ((3, 8), ()),
         ((3, 9), ()),
         ((3, 10), ()),
+        ((3, 11), ()),
     )
 
     prev: Tuple[str, ...] = ()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pyupgrade-2.15.0/pyupgrade/_plugins/generator_expressions_pep289.py 
new/pyupgrade-2.18.3/pyupgrade/_plugins/generator_expressions_pep289.py
--- old/pyupgrade-2.15.0/pyupgrade/_plugins/generator_expressions_pep289.py     
1970-01-01 01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/pyupgrade/_plugins/generator_expressions_pep289.py     
2021-05-25 04:35:17.000000000 +0200
@@ -0,0 +1,78 @@
+import ast
+from typing import Iterable
+from typing import List
+from typing import Tuple
+
+from tokenize_rt import NON_CODING_TOKENS
+from tokenize_rt import Offset
+from tokenize_rt import Token
+
+from pyupgrade._ast_helpers import ast_to_offset
+from pyupgrade._data import register
+from pyupgrade._data import State
+from pyupgrade._data import TokenFunc
+from pyupgrade._token_helpers import find_closing_bracket
+from pyupgrade._token_helpers import find_comprehension_opening_bracket
+
+
+ALLOWED_FUNCS = frozenset((
+    'bytearray',
+    'bytes',
+    'frozenset',
+    'list',
+    'max',
+    'min',
+    'sorted',
+    'sum',
+    'tuple',
+))
+
+
+def _delete_list_comp_brackets(i: int, tokens: List[Token]) -> None:
+    start = find_comprehension_opening_bracket(i, tokens)
+    end = find_closing_bracket(tokens, start)
+    tokens[end] = Token('PLACEHOLDER', '')
+    tokens[start] = Token('PLACEHOLDER', '')
+    j = end + 1
+    while j < len(tokens) and tokens[j].name in NON_CODING_TOKENS:
+        j += 1
+    if tokens[j].name == 'OP' and tokens[j].src == ',':
+        tokens[j] = Token('PLACEHOLDER', '')
+
+
+def _replace_list_comp_brackets(i: int, tokens: List[Token]) -> None:
+    start = find_comprehension_opening_bracket(i, tokens)
+    end = find_closing_bracket(tokens, start)
+    tokens[end] = Token('OP', ')')
+    tokens[start] = Token('OP', '(')
+
+
+def _func_condition(func: ast.expr) -> bool:
+    return (
+        (
+            isinstance(func, ast.Name) and
+            func.id in ALLOWED_FUNCS
+        ) or
+        (
+            isinstance(func, ast.Attribute) and
+            isinstance(func.value, ast.Str) and
+            func.attr == 'join'
+        )
+    )
+
+
+@register(ast.Call)
+def visit_Call(
+        state: State,
+        node: ast.Call,
+        parent: ast.AST,
+) -> Iterable[Tuple[Offset, TokenFunc]]:
+    if (
+            _func_condition(node.func) and
+            node.args and
+            isinstance(node.args[0], ast.ListComp)
+    ):
+        if len(node.args) == 1 and not node.keywords:
+            yield ast_to_offset(node.args[0]), _delete_list_comp_brackets
+        else:
+            yield ast_to_offset(node.args[0]), _replace_list_comp_brackets
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pyupgrade-2.15.0/pyupgrade/_plugins/identity_equality.py 
new/pyupgrade-2.18.3/pyupgrade/_plugins/identity_equality.py
--- old/pyupgrade-2.15.0/pyupgrade/_plugins/identity_equality.py        
2021-05-08 23:13:59.000000000 +0200
+++ new/pyupgrade-2.18.3/pyupgrade/_plugins/identity_equality.py        
2021-05-25 04:35:17.000000000 +0200
@@ -28,12 +28,12 @@
         tokens[i] = tokens[i]._replace(src='==')
     else:
         tokens[i] = tokens[i]._replace(src='!=')
-        # since we iterate backward, the dummy tokens keep the same length
+        # since we iterate backward, the empty tokens keep the same length
         i += 1
         while tokens[i].src != 'not':
-            tokens[i] = Token('DUMMY', '')
+            tokens[i] = Token('EMPTY', '')
             i += 1
-        tokens[i] = Token('DUMMY', '')
+        tokens[i] = Token('EMPTY', '')
 
 
 @register(ast.Compare)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/pyupgrade/_plugins/pep584.py 
new/pyupgrade-2.18.3/pyupgrade/_plugins/pep584.py
--- old/pyupgrade-2.15.0/pyupgrade/_plugins/pep584.py   1970-01-01 
01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/pyupgrade/_plugins/pep584.py   2021-05-25 
04:35:17.000000000 +0200
@@ -0,0 +1,61 @@
+import ast
+from typing import Iterable
+from typing import Tuple
+
+from tokenize_rt import List
+from tokenize_rt import NON_CODING_TOKENS
+from tokenize_rt import Offset
+from tokenize_rt import Token
+
+from pyupgrade._ast_helpers import ast_to_offset
+from pyupgrade._data import register
+from pyupgrade._data import State
+from pyupgrade._data import TokenFunc
+from pyupgrade._token_helpers import find_closing_bracket
+from pyupgrade._token_helpers import find_token
+
+
+def _replace_dict_brackets(i: int, tokens: List[Token]) -> None:
+    closing = find_closing_bracket(tokens, i)
+    j = closing - 1
+    while tokens[j].name in NON_CODING_TOKENS and j > i:
+        j -= 1
+    if tokens[j].name == 'OP' and tokens[j].src == ',':
+        tokens[j] = Token('PLACEHOLDER', '')
+
+    if tokens[i].line == tokens[closing].line:
+        tokens[i] = Token('PLACEHOLDER', '')
+        tokens[closing] = Token('PLACEHOLDER', '')
+    else:
+        tokens[i] = Token('CODE', '(')
+        tokens[closing] = Token('CODE', ')')
+
+
+def _remove_double_star(i: int, tokens: List[Token]) -> None:
+    j = i
+    while not (tokens[j].name == 'OP' and tokens[j].src == '**'):
+        j -= 1
+    tokens[j] = Token('PLACEHOLDER', '')
+
+
+def _replace_comma_with_pipe(i: int, tokens: List[Token]) -> None:
+    comma = find_token(tokens, i, ',')
+    tokens[comma] = Token('CODE', ' |')
+
+
+@register(ast.Dict)
+def visit_Dict(
+        state: State,
+        node: ast.Dict,
+        parent: ast.AST,
+) -> Iterable[Tuple[Offset, TokenFunc]]:
+    if state.settings.min_version < (3, 9):
+        return
+
+    if all(key is None for key in node.keys) and len(node.values) > 1:
+        yield ast_to_offset(node), _replace_dict_brackets
+        arg_count = len(node.values)
+        for idx, arg in enumerate(node.values):
+            yield ast_to_offset(arg), _remove_double_star
+            if idx < arg_count - 1:
+                yield ast_to_offset(arg), _replace_comma_with_pipe
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pyupgrade-2.15.0/pyupgrade/_plugins/unpack_list_comprehension.py 
new/pyupgrade-2.18.3/pyupgrade/_plugins/unpack_list_comprehension.py
--- old/pyupgrade-2.15.0/pyupgrade/_plugins/unpack_list_comprehension.py        
1970-01-01 01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/pyupgrade/_plugins/unpack_list_comprehension.py        
2021-05-25 04:35:17.000000000 +0200
@@ -0,0 +1,36 @@
+import ast
+from typing import Iterable
+from typing import List
+from typing import Tuple
+
+from tokenize_rt import Offset
+from tokenize_rt import Token
+
+from pyupgrade._ast_helpers import ast_to_offset
+from pyupgrade._data import register
+from pyupgrade._data import State
+from pyupgrade._data import TokenFunc
+from pyupgrade._token_helpers import find_closing_bracket
+from pyupgrade._token_helpers import find_comprehension_opening_bracket
+
+
+def _replace_list_comprehension(i: int, tokens: List[Token]) -> None:
+    start = find_comprehension_opening_bracket(i, tokens)
+    end = find_closing_bracket(tokens, start)
+    tokens[start] = tokens[start]._replace(src='(')
+    tokens[end] = tokens[end]._replace(src=')')
+
+
+@register(ast.Assign)
+def visit_Assign(
+        state: State,
+        node: ast.Assign,
+        parent: ast.AST,
+) -> Iterable[Tuple[Offset, TokenFunc]]:
+    if (
+            state.settings.min_version >= (3,) and
+            len(node.targets) == 1 and
+            isinstance(node.targets[0], ast.Tuple) and
+            isinstance(node.value, ast.ListComp)
+    ):
+        yield ast_to_offset(node.value), _replace_list_comprehension
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/pyupgrade/_token_helpers.py 
new/pyupgrade-2.18.3/pyupgrade/_token_helpers.py
--- old/pyupgrade-2.15.0/pyupgrade/_token_helpers.py    2021-05-08 
23:13:59.000000000 +0200
+++ new/pyupgrade-2.18.3/pyupgrade/_token_helpers.py    2021-05-25 
04:35:17.000000000 +0200
@@ -463,3 +463,14 @@
     while tokens[start_idx].name in {'UNIMPORTANT_WS', 'NL'}:
         start_idx += 1
     tokens[start_idx:end_idx] = [Token('SRC', new)]
+
+
+def find_comprehension_opening_bracket(i: int, tokens: List[Token]) -> int:
+    """Find opening bracket of comprehension given first argument."""
+    if sys.version_info < (3, 8):  # pragma: no cover (py38+)
+        i -= 1
+        while not (tokens[i].name == 'OP' and tokens[i].src == '[') and i:
+            i -= 1
+        return i
+    else:  # pragma: no cover (<py38)
+        return i
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/setup.cfg 
new/pyupgrade-2.18.3/setup.cfg
--- old/pyupgrade-2.15.0/setup.cfg      2021-05-08 23:13:59.000000000 +0200
+++ new/pyupgrade-2.18.3/setup.cfg      2021-05-25 04:35:17.000000000 +0200
@@ -1,6 +1,6 @@
 [metadata]
 name = pyupgrade
-version = 2.15.0
+version = 2.18.3
 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.15.0/tests/features/generator_expressions_pep289_test.py 
new/pyupgrade-2.18.3/tests/features/generator_expressions_pep289_test.py
--- old/pyupgrade-2.15.0/tests/features/generator_expressions_pep289_test.py    
1970-01-01 01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/tests/features/generator_expressions_pep289_test.py    
2021-05-25 04:35:17.000000000 +0200
@@ -0,0 +1,107 @@
+import pytest
+
+from pyupgrade._data import Settings
+from pyupgrade._main import _fix_plugins
+
+
[email protected](
+    ('s',),
+    (
+        pytest.param(
+            'sum((i for i in range(3)))',
+            id='Parenthesised generator expression',
+        ),
+        pytest.param(
+            'len([i for i in range(2)])',
+            id='Non-supported function',
+        ),
+        pytest.param('frozenset()', id='no arguments'),
+    ),
+)
+def test_fix_typing_text_noop(s):
+    assert _fix_plugins(s, settings=Settings()) == s
+
+
[email protected](
+    ('s', 'expected'),
+    (
+        pytest.param(
+            'sum([i for i in range(3)])\n',
+
+            'sum(i for i in range(3))\n',
+
+            id='Single line, list comprehension\n',
+        ),
+        pytest.param(
+            'sum([i for i in range(2)], 2)',
+
+            'sum((i for i in range(2)), 2)',
+
+            id='List comprehension plus posarg',
+        ),
+        pytest.param(
+            'sum([i for i in range(2)], x=2)',
+
+            'sum((i for i in range(2)), x=2)',
+
+            id='List comprehension plus kwarg',
+        ),
+        pytest.param(
+            'sum(([i for i in range(3)]))\n',
+
+            'sum((i for i in range(3)))\n',
+
+            id='Parenthesised list comprehension\n',
+        ),
+        pytest.param(
+            'sum(\n'
+            '    [i for i in range(3)]\n'
+            ')\n',
+
+            'sum(\n'
+            '    i for i in range(3)\n'
+            ')\n',
+
+            id='Multiline list comprehension\n',
+        ),
+        pytest.param(
+            'sum([[i for _ in range(2)] for i in range(3)])\n',
+
+            'sum([i for _ in range(2)] for i in range(3))\n',
+
+            id='Nested list comprehension\n',
+        ),
+        pytest.param(
+            '"".join([[i for _ in range(2)] for i in range(3)])\n',
+
+            '"".join([i for _ in range(2)] for i in range(3))\n',
+
+            id='Join function',
+        ),
+        pytest.param(
+            '"".join([[i for _ in range(2)] for i in range(3)],)\n',
+
+            '"".join([i for _ in range(2)] for i in range(3))\n',
+
+            id='Trailing comma after list comprehension',
+        ),
+        pytest.param(
+            'sum(\n'
+            '    [\n'
+            '        i for i in range(3)\n'
+            '    ],\n'
+            ')\n',
+
+            'sum(\n'
+            '    \n'
+            '        i for i in range(3)\n'
+            '    \n'
+            ')\n',
+
+            id='Multiline list comprehension with trailing comma\n',
+        ),
+    ),
+)
+def test_fix_typing_text(s, expected):
+    ret = _fix_plugins(s, settings=Settings())
+    assert ret == expected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/tests/features/typing_584_test.py 
new/pyupgrade-2.18.3/tests/features/typing_584_test.py
--- old/pyupgrade-2.15.0/tests/features/typing_584_test.py      1970-01-01 
01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/tests/features/typing_584_test.py      2021-05-25 
04:35:17.000000000 +0200
@@ -0,0 +1,97 @@
+import pytest
+
+from pyupgrade._data import Settings
+from pyupgrade._main import _fix_plugins
+
+
[email protected](
+    ('s', 'version'),
+    (
+        pytest.param(
+            '{**a, **b}\n',
+            (3, 8),
+            id='<3.9',
+        ),
+        pytest.param(
+            '{"a": 0}\n',
+            (3, 9),
+            id='Dict without merge',
+        ),
+        pytest.param(
+            'x = {**a}\n',
+            (3, 9),
+            id='Merge of only one dict',
+        ),
+    ),
+)
+def test_fix_pep584_noop(s, version):
+    assert _fix_plugins(s, settings=Settings(min_version=version)) == s
+
+
[email protected](
+    ('s', 'expected'),
+    (
+        pytest.param(
+            'x = {**a, **b}\n',
+
+            'x = a | b\n',
+
+            id='Simple dict rewrite',
+        ),
+        pytest.param(
+            'x = {**{**a, **b}, **c}\n',
+
+            'x = a | b | c\n',
+
+            id='Nested merge of dicts',
+        ),
+        pytest.param(
+            'x = {**a, **b,}\n',
+
+            'x = a | b\n',
+
+            id='Trailing comma',
+        ),
+        pytest.param(
+            'x = {\n'
+            '    **a,  # foo\n'
+            '    **b  # bar\n'
+            '}\n',
+
+            'x = (\n'
+            '    a |  # foo\n'
+            '    b  # bar\n'
+            ')\n',
+
+            id='Multiple lines with comment',
+        ),
+        pytest.param(
+            'x = {\n'
+            '    **a,\n'
+            '    **b\n'
+            '}\n',
+
+            'x = (\n'
+            '    a |\n'
+            '    b\n'
+            ')\n',
+
+            id='Multiple lines',
+        ),
+        pytest.param(
+            'x = {\n'
+            '    **a,\n'
+            '    **b,\n'
+            '}\n',
+
+            'x = (\n'
+            '    a |\n'
+            '    b\n'
+            ')\n',
+
+            id='Multiple lines, trailing comma',
+        ),
+    ),
+)
+def test_fix_pep584(s, expected):
+    assert _fix_plugins(s, settings=Settings(min_version=(3, 9))) == expected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pyupgrade-2.15.0/tests/features/unpack_list_comprehension_test.py 
new/pyupgrade-2.18.3/tests/features/unpack_list_comprehension_test.py
--- old/pyupgrade-2.15.0/tests/features/unpack_list_comprehension_test.py       
1970-01-01 01:00:00.000000000 +0100
+++ new/pyupgrade-2.18.3/tests/features/unpack_list_comprehension_test.py       
2021-05-25 04:35:17.000000000 +0200
@@ -0,0 +1,60 @@
+import pytest
+
+from pyupgrade._data import Settings
+from pyupgrade._main import _fix_plugins
+
+
[email protected](
+    ('s', 'version'),
+    (
+        pytest.param(
+            'foo, bar, baz = [fn(x) for x in items]\n',
+            (2, 7),
+            id='not python 3+',
+        ),
+        pytest.param(
+            'foo = [fn(x) for x in items]',
+            (3,),
+            id='assignment to single variable',
+        ),
+    ),
+)
+def test_fix_typing_text_noop(s, version):
+    assert _fix_plugins(s, settings=Settings(min_version=version)) == s
+
+
[email protected](
+    ('s', 'expected'),
+    (
+        pytest.param(
+            'foo, bar, baz = [fn(x) for x in items]\n',
+
+            'foo, bar, baz = (fn(x) for x in items)\n',
+
+            id='single-line assignment',
+        ),
+        pytest.param(
+            'foo, bar, baz = [[i for i in fn(x)] for x in items]\n',
+
+            'foo, bar, baz = ([i for i in fn(x)] for x in items)\n',
+
+            id='nested list comprehension',
+        ),
+        pytest.param(
+            'foo, bar, baz = [\n'
+            '    fn(x)\n'
+            '    for x in items\n'
+            ']\n',
+
+            'foo, bar, baz = (\n'
+            '    fn(x)\n'
+            '    for x in items\n'
+            ')\n',
+
+            id='multi-line assignment',
+        ),
+    ),
+)
+def test_fix_typing_text(s, expected):
+    ret = _fix_plugins(s, settings=Settings(min_version=(3,)))
+    assert ret == expected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyupgrade-2.15.0/tests/main_test.py 
new/pyupgrade-2.18.3/tests/main_test.py
--- old/pyupgrade-2.15.0/tests/main_test.py     2021-05-08 23:13:59.000000000 
+0200
+++ new/pyupgrade-2.18.3/tests/main_test.py     2021-05-25 04:35:17.000000000 
+0200
@@ -1,4 +1,5 @@
 import io
+import re
 import sys
 from unittest import mock
 
@@ -11,19 +12,12 @@
     assert main(()) == 0
 
 
[email protected](
-    'args',
-    (
-        (),
-        ('--py3-plus',),
-        ('--py36-plus',),
-        ('--py37-plus',),
-        ('--py38-plus',),
-        ('--py39-plus',),
-        ('--py310-plus',),
-    ),
-)
-def test_main_noop(tmpdir, args):
+def test_main_noop(tmpdir, capsys):
+    with pytest.raises(SystemExit):
+        main(('--help',))
+    out, err = capsys.readouterr()
+    version_options = sorted(set(re.findall(r'--py\d+-plus', out)))
+
     s = '''\
 from sys import version_info
 x=version_info
@@ -32,9 +26,14 @@
 '''
     f = tmpdir.join('f.py')
     f.write(s)
-    assert main((f.strpath, *args)) == 0
+
+    assert main((f.strpath,)) == 0
     assert f.read() == s
 
+    for version_option in version_options:
+        assert main((f.strpath, version_option)) == 0
+        assert f.read() == s
+
 
 def test_main_changes_a_file(tmpdir, capsys):
     f = tmpdir.join('f.py')

Reply via email to