diff --git a/README.md b/README.md index 4adaebe2..af4a069d 100644 --- a/README.md +++ b/README.md @@ -498,17 +498,6 @@ Availability: ``` -### Unpacking argument list comprehensions - -Availability: -- `--py3-plus` is passed on the commandline. - -```diff --foo(*[i for i in bar]) -+foo(*(i for i in bar)) -``` - - ### Rewrite `xml.etree.cElementTree` to `xml.etree.ElementTree` Availability: diff --git a/pyupgrade/_plugins/unpacking_argument_list_comprehensions.py b/pyupgrade/_plugins/unpacking_argument_list_comprehensions.py deleted file mode 100644 index 87bafd96..00000000 --- a/pyupgrade/_plugins/unpacking_argument_list_comprehensions.py +++ /dev/null @@ -1,26 +0,0 @@ -import ast -from typing import Iterable -from typing import Tuple - -from tokenize_rt import Offset - -from pyupgrade._ast_helpers import ast_to_offset -from pyupgrade._ast_helpers import is_async_listcomp -from pyupgrade._data import register -from pyupgrade._data import State -from pyupgrade._data import TokenFunc -from pyupgrade._token_helpers import replace_list_comp_brackets - - -@register(ast.Starred) -def visit_Starred( - state: State, - node: ast.Starred, - parent: ast.AST, -) -> Iterable[Tuple[Offset, TokenFunc]]: - if ( - state.settings.min_version >= (3,) and - isinstance(node.value, ast.ListComp) and - not is_async_listcomp(node.value) - ): - yield ast_to_offset(node.value), replace_list_comp_brackets diff --git a/tests/features/unpacking_argument_list_comprehensions_test.py b/tests/features/unpacking_argument_list_comprehensions_test.py deleted file mode 100644 index 7e41929d..00000000 --- a/tests/features/unpacking_argument_list_comprehensions_test.py +++ /dev/null @@ -1,80 +0,0 @@ -import pytest - -from pyupgrade._data import Settings -from pyupgrade._main import _fix_plugins - - -@pytest.mark.parametrize( - ('s', 'version'), - ( - pytest.param( - 'foo(*[i for i in bar])\n', - (2, 7), - id='Not Python3+', - ), - pytest.param( - '2*3', - (3,), - id='Multiplication star', - ), - pytest.param( - '2**3', - (3,), - id='Power star', - ), - pytest.param( - 'foo([i for i in bar])', - (3,), - id='List comp, no star', - ), - pytest.param( - 'foo(*bar)', - (3,), - id='Starred, no list comp', - ), - pytest.param( - 'foo(*[x async for x in bar])', - (3,), - id='async listcomp', - ), - ), -) -def test_fix_unpack_argument_list_comp_noop(s, version): - assert _fix_plugins(s, settings=Settings(min_version=version)) == s - - -@pytest.mark.parametrize( - ('s', 'expected'), - ( - pytest.param( - 'foo(*[i for i in bar])\n', - - 'foo(*(i for i in bar))\n', - - id='Starred list comprehension', - ), - pytest.param( - 'foo(\n' - ' *\n' - ' [i for i in bar]\n' - ' )\n', - - 'foo(\n' - ' *\n' - ' (i for i in bar)\n' - ' )\n', - - id='Multiline starred list comprehension', - ), - pytest.param( - 'foo(*[i for i in bar], qux, quox=None)\n', - - 'foo(*(i for i in bar), qux, quox=None)\n', - - id='Single line, including other args', - ), - ), -) -def test_fix_unpack_argument_list_comp(s, expected): - ret = _fix_plugins(s, settings=Settings((3,))) - assert ret == expected