Skip to content

Commit

Permalink
move to xfail
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 13, 2021
1 parent e96e13b commit c3d71b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
7 changes: 1 addition & 6 deletions pyupgrade/_plugins/versioned_branches.py
Expand Up @@ -188,10 +188,5 @@ def visit_If(
):
if node.orelse and not isinstance(node.orelse[0], ast.If):
yield ast_to_offset(node), _fix_py3_block_else
elif not node.orelse and min_version == (3, 0):
# allow >= (3,) and > (3,) to be dedented even without
# an else clause, as a special cases
elif not node.orelse:
yield ast_to_offset(node), _fix_py3_block
else:
# don't try to fix, e.g., >= (3, 6) if there's no else clause
yield ast_to_offset(node), lambda i, tokens: None
27 changes: 18 additions & 9 deletions tests/features/versioned_branches_test.py
Expand Up @@ -555,15 +555,6 @@ def test_fix_py3x_only_code(s, expected):
@pytest.mark.parametrize(
's',
(
# we timidly skip `if` without `else` as it could cause a SyntaxError
'import sys\n'
'if sys.version_info >= (3, 6):\n'
' pass',
# here's the case where it causes a SyntaxError
'import sys\n'
'if True:\n'
' if sys.version_info >= (3, 6):\n'
' pass\n',
# both branches are still relevant in the following cases
'import sys\n'
'if sys.version_info > (3, 7):\n'
Expand Down Expand Up @@ -600,7 +591,25 @@ def test_fix_py3x_only_code(s, expected):
' 3+7\n'
'else:\n'
' 3-6\n',
# this one *could* be fixed, it's just not implemented yet
# see test_no_else_py3x_only_code
'import sys\n'
'if sys.version_info >= (3, 6):\n'
' pass',
),
)
def test_fix_py3x_only_noop(s):
assert _fix_plugins(s, settings=Settings(min_version=(3, 6))) == s


@pytest.mark.xfail(reason='not implemented')
def test_no_else_py3x_only_code():

s = (
'import sys\n'
'if sys.version_info >= (3, 6):\n'
' pass'
)
expected = 'import sys\n'
assert _fix_plugins(s, settings=Settings(min_version=(3, 6))) == expected

0 comments on commit c3d71b9

Please sign in to comment.