diff --git a/pyupgrade.py b/pyupgrade.py
index ac8bd70..b26904c 100644
--- a/pyupgrade.py
+++ b/pyupgrade.py
@@ -961,6 +961,10 @@ class FindPy3Plus(ast.NodeVisitor):
         self.bases_to_remove = set()
 
         self.encode_calls = {}
+
+        self.if_py2_blocks = set()
+        self.if_py3_blocks = set()
+
         self.native_literals = set()
 
         self._six_from_imports = set()
@@ -1106,11 +1110,162 @@ class FindPy3Plus(ast.NodeVisitor):
 
         self.generic_visit(node)
 
-    def generic_visit(self, node):
+    def visit_If(self, node):  # type: (ast.If) -> None
+        if node.orelse and not isinstance(node.orelse[0], ast.If):
+            if (
+                    # if six.PY2:
+                    self._is_six(node.test, ('PY2',)) or
+                    # if not six.PY3:
+                    (
+                        isinstance(node.test, ast.UnaryOp) and
+                        isinstance(node.test.op, ast.Not) and
+                        self._is_six(node.test.operand, ('PY3',))
+                    )
+            ):
+                self.if_py2_blocks.add(_ast_to_offset(node))
+            elif (
+                    # if six.PY3:
+                    self._is_six(node.test, 'PY3') or
+                    # if not six.PY2:
+                    (
+                        isinstance(node.test, ast.UnaryOp) and
+                        isinstance(node.test.op, ast.Not) and
+                        self._is_six(node.test.operand, ('PY2',))
+                    )
+            ):
+                self.if_py3_blocks.add(_ast_to_offset(node))
+        self.generic_visit(node)
+
+    def generic_visit(self, node):  # type: (ast.AST) -> None
         self._previous_node = node
         super(FindPy3Plus, self).generic_visit(node)
 
 
+def _fixup_dedent_tokens(tokens):
+    """For whatever reason the DEDENT / UNIMPORTANT_WS tokens are misordered
+
+    | if True:
+    |     if True:
+    |         pass
+    |     else:
+    |^    ^- DEDENT
+    |+----UNIMPORTANT_WS
+    """
+    for i, token in enumerate(tokens):
+        if token.name == UNIMPORTANT_WS and tokens[i + 1].name == 'DEDENT':
+            tokens[i], tokens[i + 1] = tokens[i + 1], tokens[i]
+
+
+def _find_block_start(tokens, i):
+    depth = 0
+    while depth or tokens[i].src != ':':
+        depth += {'(': 1, ')': -1}.get(tokens[i].src, 0)
+        i += 1
+    return i
+
+
+class Block(
+        collections.namedtuple('Block', ('start', 'block', 'end', 'line')),
+):
+    __slots__ = ()
+
+    def _initial_indent(self, tokens):
+        if tokens[self.start].src.isspace():
+            return len(tokens[self.start].src)
+        else:
+            return 0
+
+    def _minimum_indent(self, tokens):
+        block_indent = None
+        for i in range(self.block, self.end):
+            if (
+                    tokens[i - 1].name in ('NL', 'NEWLINE') and
+                    tokens[i].name in ('INDENT', UNIMPORTANT_WS)
+            ):
+                token_indent = len(tokens[i].src)
+                if block_indent is None:
+                    block_indent = token_indent
+                else:
+                    block_indent = min(block_indent, token_indent)
+        return block_indent
+
+    def dedent(self, tokens):
+        if self.line:
+            return
+        diff = self._minimum_indent(tokens) - self._initial_indent(tokens)
+        for i in range(self.block, self.end):
+            if (
+                    tokens[i - 1].name in ('NL', 'NEWLINE') and
+                    tokens[i].name in ('INDENT', UNIMPORTANT_WS)
+            ):
+                tokens[i] = tokens[i]._replace(src=tokens[i].src[diff:])
+
+    def _trim_end(self, tokens):
+        """the tokenizer reports the end of the block at the beginning of
+        the next block
+        """
+        i = last_token = self.end - 1
+        while tokens[i].name in NON_CODING_TOKENS | {'DEDENT', 'NEWLINE'}:
+            # if we find an indented comment inside our block, keep it
+            if (
+                    tokens[i].name in {'NL', 'NEWLINE'} and
+                    tokens[i + 1].name == UNIMPORTANT_WS and
+                    len(tokens[i + 1].src) > self._initial_indent(tokens)
+            ):
+                break
+            # otherwise we've found another line to remove
+            elif tokens[i].name in {'NL', 'NEWLINE'}:
+                last_token = i
+            i -= 1
+        return self._replace(end=last_token + 1)
+
+    @classmethod
+    def find(cls, tokens, i, trim_end=False):
+        if i > 0 and tokens[i - 1].name in {'INDENT', UNIMPORTANT_WS}:
+            i -= 1
+        start = i
+        colon = _find_block_start(tokens, i)
+
+        j = colon + 1
+        while (
+                tokens[j].name != 'NEWLINE' and
+                tokens[j].name in NON_CODING_TOKENS
+        ):
+            j += 1
+
+        if tokens[j].name == 'NEWLINE':  # multi line block
+            block = j + 1
+            while tokens[j].name != 'INDENT':
+                j += 1
+            level = 1
+            j += 1
+            while level:
+                level += {'INDENT': 1, 'DEDENT': -1}.get(tokens[j].name, 0)
+                j += 1
+            if trim_end:
+                return cls(start, block, j, line=False)._trim_end(tokens)
+            else:
+                return cls(start, block, j, line=False)
+        else:  # single line block
+            block = j
+            # search forward until the NEWLINE token
+            while tokens[j].name not in {'NEWLINE', 'ENDMARKER'}:
+                j += 1
+            # we also want to include the newline in the block
+            if tokens[j].name == 'NEWLINE':  # pragma: no branch (PY2 only)
+                j += 1
+            return cls(start, block, j, line=True)
+
+
+def _find_if_else_block(tokens, i):
+    if_block = Block.find(tokens, i)
+    i = if_block.end
+    while tokens[i].src != 'else':
+        i += 1
+    else_block = Block.find(tokens, i, trim_end=True)
+    return if_block, else_block
+
+
 def _remove_decorator(tokens, i):
     while tokens[i - 1].src != '@':
         i -= 1
@@ -1236,6 +1391,8 @@ def _fix_py3_plus(contents_text):
     if not any((
             visitor.bases_to_remove,
             visitor.encode_calls,
+            visitor.if_py2_blocks,
+            visitor.if_py3_blocks,
             visitor.native_literals,
             visitor.six_add_metaclass,
             visitor.six_b,
@@ -1254,6 +1411,8 @@ def _fix_py3_plus(contents_text):
     except tokenize.TokenError:  # pragma: no cover (bpo-2180)
         return contents_text
 
+    _fixup_dedent_tokens(tokens)
+
     def _replace(i, mapping, node):
         new_token = Token('CODE', _get_tmpl(mapping, node))
         if isinstance(node, ast.Name):
@@ -1269,6 +1428,21 @@ def _fix_py3_plus(contents_text):
             continue
         elif token.offset in visitor.bases_to_remove:
             _remove_base_class(tokens, i)
+        elif token.offset in visitor.if_py2_blocks:
+            if tokens[i].src != 'if':
+                continue
+            if_block, else_block = _find_if_else_block(tokens, i)
+
+            else_block.dedent(tokens)
+            del tokens[if_block.start:else_block.block]
+        elif token.offset in visitor.if_py3_blocks:
+            if tokens[i].src != 'if':
+                continue
+            if_block, else_block = _find_if_else_block(tokens, i)
+
+            if_block.dedent(tokens)
+            del tokens[if_block.end:else_block.end]
+            del tokens[if_block.start:if_block.block]
         elif token.offset in visitor.six_type_ctx:
             _replace(i, SIX_TYPE_CTX_ATTRS, visitor.six_type_ctx[token.offset])
         elif token.offset in visitor.six_simple:
@@ -1305,16 +1479,13 @@ def _fix_py3_plus(contents_text):
             j = i + 1
             while tokens[j].src != 'class':
                 j += 1
+            class_token = j
             # then search forward for a `:` token, not inside a brace
-            depth = 0
+            j = _find_block_start(tokens, j)
             last_paren = -1
-            while depth or tokens[j].src != ':':
-                if tokens[j].src == '(':
-                    depth += 1
-                elif tokens[j].src == ')':
-                    depth -= 1
-                    last_paren = j
-                j += 1
+            for k in range(class_token, j):
+                if tokens[k].src == ')':
+                    last_paren = k
 
             if last_paren == -1:
                 tokens.insert(j, Token('CODE', '({})'.format(metaclass)))

diff --git a/tests/pyupgrade_test.py b/tests/pyupgrade_test.py
index 87ac751..070c9fe 100644
--- a/tests/pyupgrade_test.py
+++ b/tests/pyupgrade_test.py
@@ -1493,6 +1493,274 @@ def test_fix_encode_noop(s):
     assert _fix_py3_plus(s) == s
 
 
+@pytest.mark.parametrize(
+    's',
+    (
+        # we timidly skip `if` without `else` as it could cause a SyntaxError
+        'if six.PY2:\n'
+        '    pass',
+        # here's the case where it causes a SyntaxError
+        'if True:\n'
+        '    if six.PY2:\n'
+        '        pass\n',
+        # for now we don't attempt to rewrite `elif`
+        'if False:\n'
+        '    pass\n'
+        'elif six.PY3:\n'
+        '    pass\n'
+        'else:\n'
+        '    pass\n',
+        'if False:\n'
+        '    pass\n'
+        'elif six.PY2:\n'
+        '    pass\n'
+        'else:\n'
+        '    pass\n',
+    ),
+)
+def test_fix_py2_block_noop(s):
+    assert _fix_py3_plus(s) == s
+
+
+@pytest.mark.parametrize(
+    ('s', 'expected'),
+    (
+        pytest.param(
+            'if six.PY2:\n'
+            '    print("py2")\n'
+            'else:\n'
+            '    print("py3")\n',
+
+            'print("py3")\n',
+
+            id='six.PY2',
+        ),
+        pytest.param(
+            'if six.PY2:\n'
+            '    if True:\n'
+            '        print("py2!")\n'
+            '    else:\n'
+            '        print("???")\n'
+            'else:\n'
+            '    print("py3")\n',
+
+            'print("py3")\n',
+
+            id='six.PY2, nested ifs',
+        ),
+        pytest.param(
+            'if six.PY2: print("PY2!")\n'
+            'else:       print("PY3!")\n',
+
+            'print("PY3!")\n',
+
+            id='six.PY2, oneline',
+        ),
+        pytest.param(
+            'if six.PY2: print("PY2!")\n'
+            'else:       print("PY3!")',
+
+            'print("PY3!")',
+
+            id='six.PY2, oneline, no newline at end of file',
+        ),
+        pytest.param(
+            'if True:\n'
+            '    if six.PY2:\n'
+            '        print("PY2")\n'
+            '    else:\n'
+            '        print("PY3")\n',
+
+            'if True:\n'
+            '    print("PY3")\n',
+
+            id='six.PY2, indented',
+        ),
+        pytest.param(
+            'if six.PY2: print(1 if True else 3)\n'
+            'else:\n'
+            '   print("py3")\n',
+
+            'print("py3")\n',
+
+            id='six.PY2, `else` token inside oneline if\n',
+        ),
+        pytest.param(
+            'if six.PY2:\n'
+            '    def f():\n'
+            '        print("py2")\n'
+            'else:\n'
+            '    def f():\n'
+            '        print("py3")\n',
+
+            'def f():\n'
+            '    print("py3")\n',
+
+            id='six.PY2, multiple indents in block',
+        ),
+        pytest.param(
+            'if not six.PY2:\n'
+            '    print("py3")\n'
+            'else:\n'
+            '    print("py2")\n'
+            '\n'
+            '\n'
+            'x = 1\n',
+
+            'print("py3")\n'
+            '\n'
+            '\n'
+            'x = 1\n',
+
+            id='not six.PY2, remove second block',
+        ),
+        pytest.param(
+            'if not six.PY2:\n'
+            '    print("py3")\n'
+            'else:\n'
+            '    print("py2")',
+
+            'print("py3")\n',
+
+            id='not six.PY2, no end of line',
+        ),
+        pytest.param(
+            'if not six.PY2:\n'
+            '    print("py3")\n'
+            'else:\n'
+            '    print("py2")\n'
+            '    # ohai\n'
+            '\n'
+            'x = 1\n',
+
+            'print("py3")\n'
+            '\n'
+            'x = 1\n',
+
+            id='not six.PY2: else block ends in comment',
+        ),
+        pytest.param(
+            'if not six.PY2: print("py3")\n'
+            'else: print("py2")\n',
+
+            'print("py3")\n',
+
+            id='not six.PY2, else is single line',
+        ),
+        pytest.param(
+            'if six.PY3:\n'
+            '    print("py3")\n'
+            'else:\n'
+            '    print("py2")\n',
+
+            'print("py3")\n',
+
+            id='six.PY3',
+        ),
+        pytest.param(
+            'if True:\n'
+            '    if six.PY3:\n'
+            '        print("py3")\n'
+            '    else:\n'
+            '        print("py2")\n',
+
+            'if True:\n'
+            '    print("py3")\n',
+
+            id='indented six.PY3',
+        ),
+        pytest.param(
+            'from six import PY3\n'
+            'if not PY3:\n'
+            '    print("py2")\n'
+            'else:\n'
+            '    print("py3")\n',
+
+            'from six import PY3\n'
+            'print("py3")\n',
+
+            id='not PY3',
+        ),
+        pytest.param(
+            'def f():\n'
+            '    if six.PY2:\n'
+            '        try:\n'
+            '            yield\n'
+            '        finally:\n'
+            '            pass\n'
+            '    else:\n'
+            '        yield\n',
+
+            'def f():\n'
+            '    yield\n',
+
+            id='six.PY2, finally',
+        ),
+        pytest.param(
+            'class C:\n'
+            '    def g():\n'
+            '        pass\n'
+            '\n'
+            '    if six.PY2:\n'
+            '        def f(py2):\n'
+            '            pass\n'
+            '    else:\n'
+            '        def f(py3):\n'
+            '            pass\n'
+            '\n'
+            '    def h():\n'
+            '        pass\n',
+
+            'class C:\n'
+            '    def g():\n'
+            '        pass\n'
+            '\n'
+            '    def f(py3):\n'
+            '        pass\n'
+            '\n'
+            '    def h():\n'
+            '        pass\n',
+
+            id='six.PY2 in class\n',
+        ),
+        pytest.param(
+            'if True:\n'
+            '    if six.PY2:\n'
+            '        2\n'
+            '    else:\n'
+            '        3\n'
+            '\n'
+            '    # comment\n',
+
+            'if True:\n'
+            '    3\n'
+            '\n'
+            '    # comment\n',
+
+            id='six.PY2, comment after',
+        ),
+        pytest.param(
+            'if True:\n'
+            '    if six.PY3:\n'
+            '        3\n'
+            '    else:\n'
+            '        2\n'
+            '\n'
+            '    # comment\n',
+
+            'if True:\n'
+            '    3\n'
+            '\n'
+            '    # comment\n',
+
+            id='six.PY3, comment after',
+        ),
+    ),
+)
+def test_fix_py2_blocks(s, expected):
+    assert _fix_py3_plus(s) == expected
+
+
 @pytest.mark.parametrize(
     's',
     (

Rewrite `if PY2:` blocks in `--py3-plus`
Ideally handle these different cases:

```python
# input
from six import PY2
if PY2:
   x = 5
else:
   x = 6
# output
x = 6
```

But also for

```python
sys.version_info[0] == 2
sys.version_info < (3,)
```
etc.

- [x] `six.PY2`
- [x] `six.PY3`
- [x] `not six.PY2`
- [x] `not six.PY3`
- [ ] `sys.version_info >= (3,)`
- [ ] `sys.version_info < (3,)`
- [ ] `sys.version_info[0] == 2`
- [ ] `sys.version_info[0] == 3`
tests/pyupgrade_test.py::test_fix_py2_blocks[six.PY2] tests/pyupgrade_test.py::test_fix_py2_blocks[six.PY2, tests/pyupgrade_test.py::test_fix_py2_blocks[not tests/pyupgrade_test.py::test_fix_py2_blocks[six.PY3] tests/pyupgrade_test.py::test_fix_py2_blocks[indented tests/pyupgrade_test.py::test_fix_py2_blocks[six.PY2 tests/pyupgrade_test.py::test_fix_py2_blocks[six.PY3,
tests/pyupgrade_test.py::test_roundtrip_text[] tests/pyupgrade_test.py::test_roundtrip_text[foo] tests/pyupgrade_test.py::test_roundtrip_text[{}] tests/pyupgrade_test.py::test_roundtrip_text[{0}] tests/pyupgrade_test.py::test_roundtrip_text[{named}] tests/pyupgrade_test.py::test_roundtrip_text[{!r}] tests/pyupgrade_test.py::test_roundtrip_text[{:>5}] tests/pyupgrade_test.py::test_roundtrip_text[{{] tests/pyupgrade_test.py::test_roundtrip_text[}}] tests/pyupgrade_test.py::test_roundtrip_text[{0!s:15}] tests/pyupgrade_test.py::test_intentionally_not_round_trip[{:}-{}] tests/pyupgrade_test.py::test_intentionally_not_round_trip[{0:}-{0}] tests/pyupgrade_test.py::test_intentionally_not_round_trip[{0!r:}-{0!r}] tests/pyupgrade_test.py::test_sets[set()-set()] tests/pyupgrade_test.py::test_sets[set((\n))-set((\n))] tests/pyupgrade_test.py::test_sets[set tests/pyupgrade_test.py::test_sets[set(())-set()] tests/pyupgrade_test.py::test_sets[set([])-set()] tests/pyupgrade_test.py::test_sets[set(( tests/pyupgrade_test.py::test_sets[set((1, tests/pyupgrade_test.py::test_sets[set([1, tests/pyupgrade_test.py::test_sets[set(x tests/pyupgrade_test.py::test_sets[set([x tests/pyupgrade_test.py::test_sets[set((x tests/pyupgrade_test.py::test_sets[set(((1, tests/pyupgrade_test.py::test_sets[set((a, tests/pyupgrade_test.py::test_sets[set([(1, tests/pyupgrade_test.py::test_sets[set(\n tests/pyupgrade_test.py::test_sets[set([((1, tests/pyupgrade_test.py::test_sets[set((((1, tests/pyupgrade_test.py::test_sets[set(\n(1, tests/pyupgrade_test.py::test_sets[set((\n1,\n2,\n))\n-{\n1,\n2,\n}\n] tests/pyupgrade_test.py::test_sets[set((frozenset(set((1, tests/pyupgrade_test.py::test_sets[set((1,))-{1}] tests/pyupgrade_test.py::test_dictcomps[x tests/pyupgrade_test.py::test_dictcomps[dict()-dict()] tests/pyupgrade_test.py::test_dictcomps[(-(] tests/pyupgrade_test.py::test_dictcomps[dict tests/pyupgrade_test.py::test_dictcomps[dict((a, tests/pyupgrade_test.py::test_dictcomps[dict([a, tests/pyupgrade_test.py::test_dictcomps[dict(((a, tests/pyupgrade_test.py::test_dictcomps[dict([(a, tests/pyupgrade_test.py::test_dictcomps[dict(((a), tests/pyupgrade_test.py::test_dictcomps[dict((k, tests/pyupgrade_test.py::test_dictcomps[dict(\n tests/pyupgrade_test.py::test_dictcomps[x(\n tests/pyupgrade_test.py::test_fix_is_compare_to_literal_noop[x tests/pyupgrade_test.py::test_fix_is_compare_to_literal[`is`] tests/pyupgrade_test.py::test_fix_is_compare_to_literal[`is tests/pyupgrade_test.py::test_fix_is_compare_to_literal[string] tests/pyupgrade_test.py::test_fix_is_compare_to_literal[unicode tests/pyupgrade_test.py::test_fix_is_compare_to_literal[bytes] tests/pyupgrade_test.py::test_fix_is_compare_to_literal[float] tests/pyupgrade_test.py::test_fix_is_compare_to_literal[compound tests/pyupgrade_test.py::test_fix_is_compare_to_literal[multi-line tests/pyupgrade_test.py::test_format_literals["{0}"format(1)-"{0}"format(1)] tests/pyupgrade_test.py::test_format_literals['{}'.format(1)-'{}'.format(1)] tests/pyupgrade_test.py::test_format_literals['{'.format(1)-'{'.format(1)] tests/pyupgrade_test.py::test_format_literals['}'.format(1)-'}'.format(1)] tests/pyupgrade_test.py::test_format_literals[x tests/pyupgrade_test.py::test_format_literals['{0} tests/pyupgrade_test.py::test_format_literals['{0}'.format(1)-'{}'.format(1)] tests/pyupgrade_test.py::test_format_literals['{0:x}'.format(30)-'{:x}'.format(30)] tests/pyupgrade_test.py::test_format_literals['''{0}\n{1}\n'''.format(1, tests/pyupgrade_test.py::test_format_literals['{0}' tests/pyupgrade_test.py::test_format_literals[print(\n tests/pyupgrade_test.py::test_format_literals['{0:<{1}}'.format(1, tests/pyupgrade_test.py::test_imports_unicode_literals[import tests/pyupgrade_test.py::test_imports_unicode_literals[from tests/pyupgrade_test.py::test_imports_unicode_literals[x tests/pyupgrade_test.py::test_imports_unicode_literals["""docstring"""\nfrom tests/pyupgrade_test.py::test_unicode_literals[(-False-(] tests/pyupgrade_test.py::test_unicode_literals[u''-False-u''] tests/pyupgrade_test.py::test_unicode_literals[u''-True-''] tests/pyupgrade_test.py::test_unicode_literals[from tests/pyupgrade_test.py::test_unicode_literals["""with tests/pyupgrade_test.py::test_unicode_literals[Regression: tests/pyupgrade_test.py::test_fix_ur_literals[basic tests/pyupgrade_test.py::test_fix_ur_literals[upper tests/pyupgrade_test.py::test_fix_ur_literals[with tests/pyupgrade_test.py::test_fix_ur_literals[emoji] tests/pyupgrade_test.py::test_fix_ur_literals_gets_fixed_before_u_removed tests/pyupgrade_test.py::test_fix_escape_sequences_noop[""] tests/pyupgrade_test.py::test_fix_escape_sequences_noop[r"\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop[r'\\d'] tests/pyupgrade_test.py::test_fix_escape_sequences_noop[r"""\\d"""] tests/pyupgrade_test.py::test_fix_escape_sequences_noop[r'''\\d'''] tests/pyupgrade_test.py::test_fix_escape_sequences_noop[rb"\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["\\\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["\\u2603"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["\\r\\n"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["\\N{SNOWMAN}"] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["""\\\n"""] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["""\\\r\n"""] tests/pyupgrade_test.py::test_fix_escape_sequences_noop["""\\\r"""] tests/pyupgrade_test.py::test_fix_escape_sequences["\\d"-r"\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences["\\n\\d"-"\\n\\\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences[u"\\d"-u"\\\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences[b"\\d"-br"\\d"] tests/pyupgrade_test.py::test_fix_escape_sequences["\\8"-r"\\8"] tests/pyupgrade_test.py::test_fix_escape_sequences["\\9"-r"\\9"] tests/pyupgrade_test.py::test_fix_escape_sequences[b"\\u2603"-br"\\u2603"] tests/pyupgrade_test.py::test_fix_escape_sequences["""\\\n\\q"""-"""\\\n\\\\q"""] tests/pyupgrade_test.py::test_fix_escape_sequences["""\\\r\n\\q"""-"""\\\r\n\\\\q"""] tests/pyupgrade_test.py::test_fix_escape_sequences["""\\\r\\q"""-"""\\\r\\\\q"""] tests/pyupgrade_test.py::test_fix_escape_sequences["\\N"-r"\\N"] tests/pyupgrade_test.py::test_fix_escape_sequences["\\N\\n"-"\\\\N\\n"] tests/pyupgrade_test.py::test_fix_escape_sequences["\\N{SNOWMAN}\\q"-"\\N{SNOWMAN}\\\\q"] tests/pyupgrade_test.py::test_fix_escape_sequences[b"\\N{SNOWMAN}"-br"\\N{SNOWMAN}"] tests/pyupgrade_test.py::test_noop_octal_literals[0] tests/pyupgrade_test.py::test_noop_octal_literals[00] tests/pyupgrade_test.py::test_noop_octal_literals[1] tests/pyupgrade_test.py::test_noop_octal_literals[12345] tests/pyupgrade_test.py::test_noop_octal_literals[1.2345] tests/pyupgrade_test.py::test_fix_extra_parens_noop[print("hello tests/pyupgrade_test.py::test_fix_extra_parens_noop[print((1, tests/pyupgrade_test.py::test_fix_extra_parens_noop[print(())] tests/pyupgrade_test.py::test_fix_extra_parens_noop[print((\n))] tests/pyupgrade_test.py::test_fix_extra_parens_noop[sum((block.code tests/pyupgrade_test.py::test_fix_extra_parens_noop[def tests/pyupgrade_test.py::test_fix_extra_parens[print(("hello tests/pyupgrade_test.py::test_fix_extra_parens[print(("foo{}".format(1)))-print("foo{}".format(1))] tests/pyupgrade_test.py::test_fix_extra_parens[print((((1))))-print(1)] tests/pyupgrade_test.py::test_fix_extra_parens[print(\n tests/pyupgrade_test.py::test_fix_extra_parens[extra tests/pyupgrade_test.py::test_is_bytestring_true[b''] tests/pyupgrade_test.py::test_is_bytestring_true[b""] tests/pyupgrade_test.py::test_is_bytestring_true[B""] tests/pyupgrade_test.py::test_is_bytestring_true[B''] tests/pyupgrade_test.py::test_is_bytestring_true[rb''0] tests/pyupgrade_test.py::test_is_bytestring_true[rb''1] tests/pyupgrade_test.py::test_is_bytestring_false[] tests/pyupgrade_test.py::test_is_bytestring_false[""] tests/pyupgrade_test.py::test_is_bytestring_false[''] tests/pyupgrade_test.py::test_is_bytestring_false[u""] tests/pyupgrade_test.py::test_is_bytestring_false["b"] tests/pyupgrade_test.py::test_parse_percent_format[""-expected0] tests/pyupgrade_test.py::test_parse_percent_format["%%"-expected1] tests/pyupgrade_test.py::test_parse_percent_format["%s"-expected2] tests/pyupgrade_test.py::test_parse_percent_format["%s tests/pyupgrade_test.py::test_parse_percent_format["%(hi)s"-expected4] tests/pyupgrade_test.py::test_parse_percent_format["%()s"-expected5] tests/pyupgrade_test.py::test_parse_percent_format["%#o"-expected6] tests/pyupgrade_test.py::test_parse_percent_format["% tests/pyupgrade_test.py::test_parse_percent_format["%5d"-expected8] tests/pyupgrade_test.py::test_parse_percent_format["%*d"-expected9] tests/pyupgrade_test.py::test_parse_percent_format["%.f"-expected10] tests/pyupgrade_test.py::test_parse_percent_format["%.5f"-expected11] tests/pyupgrade_test.py::test_parse_percent_format["%.*f"-expected12] tests/pyupgrade_test.py::test_parse_percent_format["%ld"-expected13] tests/pyupgrade_test.py::test_parse_percent_format["%(complete)#4.4f"-expected14] tests/pyupgrade_test.py::test_percent_to_format[%s-{}] tests/pyupgrade_test.py::test_percent_to_format[%%%s-%{}] tests/pyupgrade_test.py::test_percent_to_format[%(foo)s-{foo}] tests/pyupgrade_test.py::test_percent_to_format[%2f-{:2f}] tests/pyupgrade_test.py::test_percent_to_format[%r-{!r}] tests/pyupgrade_test.py::test_percent_to_format[%a-{!a}] tests/pyupgrade_test.py::test_simplify_conversion_flag[-] tests/pyupgrade_test.py::test_simplify_conversion_flag[ tests/pyupgrade_test.py::test_simplify_conversion_flag[#0- tests/pyupgrade_test.py::test_simplify_conversion_flag[--<] tests/pyupgrade_test.py::test_percent_format_noop["%s" tests/pyupgrade_test.py::test_percent_format_noop[b"%s" tests/pyupgrade_test.py::test_percent_format_noop["%*s" tests/pyupgrade_test.py::test_percent_format_noop["%.*s" tests/pyupgrade_test.py::test_percent_format_noop["%d" tests/pyupgrade_test.py::test_percent_format_noop["%i" tests/pyupgrade_test.py::test_percent_format_noop["%u" tests/pyupgrade_test.py::test_percent_format_noop["%c" tests/pyupgrade_test.py::test_percent_format_noop["%#o" tests/pyupgrade_test.py::test_percent_format_noop["%()s" tests/pyupgrade_test.py::test_percent_format_noop["%4%" tests/pyupgrade_test.py::test_percent_format_noop["%.2r" tests/pyupgrade_test.py::test_percent_format_noop["%.2a" tests/pyupgrade_test.py::test_percent_format_noop[i tests/pyupgrade_test.py::test_percent_format_noop["%(1)s" tests/pyupgrade_test.py::test_percent_format_noop["%(a)s" tests/pyupgrade_test.py::test_percent_format_noop["%(ab)s" tests/pyupgrade_test.py::test_percent_format_noop["%(and)s" tests/pyupgrade_test.py::test_percent_format["trivial" tests/pyupgrade_test.py::test_percent_format["%s" tests/pyupgrade_test.py::test_percent_format["%s%% tests/pyupgrade_test.py::test_percent_format["%3f" tests/pyupgrade_test.py::test_percent_format["%-5s" tests/pyupgrade_test.py::test_percent_format["%9s" tests/pyupgrade_test.py::test_percent_format["brace tests/pyupgrade_test.py::test_percent_format["%(k)s" tests/pyupgrade_test.py::test_percent_format["%(to_list)s" tests/pyupgrade_test.py::test_fix_super_noop[x(] tests/pyupgrade_test.py::test_fix_super_noop[class tests/pyupgrade_test.py::test_fix_super_noop[def tests/pyupgrade_test.py::test_fix_super[class tests/pyupgrade_test.py::test_fix_classes_noop[x tests/pyupgrade_test.py::test_fix_classes_noop[class tests/pyupgrade_test.py::test_fix_classes[class tests/pyupgrade_test.py::test_fix_classes[import tests/pyupgrade_test.py::test_fix_classes[from tests/pyupgrade_test.py::test_fix_six_noop[x tests/pyupgrade_test.py::test_fix_six_noop[from tests/pyupgrade_test.py::test_fix_six_noop[@mydec\nclass tests/pyupgrade_test.py::test_fix_six_noop[print(six.raise_from(exc, tests/pyupgrade_test.py::test_fix_six_noop[print(six.b("\xa3"))] tests/pyupgrade_test.py::test_fix_six_noop[print(six.b( tests/pyupgrade_test.py::test_fix_six_noop[class tests/pyupgrade_test.py::test_fix_six_noop[six.reraise(*err)] tests/pyupgrade_test.py::test_fix_six_noop[six.b(*a)] tests/pyupgrade_test.py::test_fix_six_noop[six.u(*a)] tests/pyupgrade_test.py::test_fix_six_noop[@six.add_metaclass(*a)\nclass tests/pyupgrade_test.py::test_fix_six[isinstance(s, tests/pyupgrade_test.py::test_fix_six[weird tests/pyupgrade_test.py::test_fix_six[issubclass(tp, tests/pyupgrade_test.py::test_fix_six[STRING_TYPES tests/pyupgrade_test.py::test_fix_six[from tests/pyupgrade_test.py::test_fix_six[six.b("123")-b"123"] tests/pyupgrade_test.py::test_fix_six[six.b(r"123")-br"123"] tests/pyupgrade_test.py::test_fix_six[six.b("\\x12\\xef")-b"\\x12\\xef"] tests/pyupgrade_test.py::test_fix_six[six.byte2int(b"f")-b"f"[0]] tests/pyupgrade_test.py::test_fix_six[@six.python_2_unicode_compatible\nclass tests/pyupgrade_test.py::test_fix_six[@six.python_2_unicode_compatible\n@other_decorator\nclass tests/pyupgrade_test.py::test_fix_six[six.get_unbound_method(meth)\n-meth\n] tests/pyupgrade_test.py::test_fix_six[six.indexbytes(bs, tests/pyupgrade_test.py::test_fix_six[six.assertCountEqual(\n tests/pyupgrade_test.py::test_fix_six[six.raise_from(exc, tests/pyupgrade_test.py::test_fix_six[six.reraise(tp, tests/pyupgrade_test.py::test_fix_six[six.reraise(\n tests/pyupgrade_test.py::test_fix_six[class tests/pyupgrade_test.py::test_fix_six[basic tests/pyupgrade_test.py::test_fix_six[add_metaclass, tests/pyupgrade_test.py::test_fix_classes_py3only[class tests/pyupgrade_test.py::test_fix_classes_py3only[from tests/pyupgrade_test.py::test_fix_native_literals_noop[str(1)] tests/pyupgrade_test.py::test_fix_native_literals_noop[str("foo"\n"bar")] tests/pyupgrade_test.py::test_fix_native_literals_noop[str(*a)] tests/pyupgrade_test.py::test_fix_native_literals_noop[str("foo", tests/pyupgrade_test.py::test_fix_native_literals_noop[str(**k)] tests/pyupgrade_test.py::test_fix_native_literals[str("foo")-"foo"] tests/pyupgrade_test.py::test_fix_native_literals[str("""\nfoo""")-"""\nfoo"""] tests/pyupgrade_test.py::test_fix_encode["asd".encode("utf-8")-"asd".encode()] tests/pyupgrade_test.py::test_fix_encode["asd".encode("utf8")-"asd".encode()] tests/pyupgrade_test.py::test_fix_encode["asd".encode("UTF-8")-"asd".encode()] tests/pyupgrade_test.py::test_fix_encode[sys.stdout.buffer.write(\n tests/pyupgrade_test.py::test_fix_encode_noop["asd".encode("unknown-codec")] tests/pyupgrade_test.py::test_fix_encode_noop["asd".encode("ascii")] tests/pyupgrade_test.py::test_fix_encode_noop[x="asd"\nx.encode("utf-8")] tests/pyupgrade_test.py::test_fix_encode_noop["asd".encode("utf-8", tests/pyupgrade_test.py::test_fix_encode_noop["asd".encode(encoding="utf-8")] tests/pyupgrade_test.py::test_fix_py2_block_noop[if tests/pyupgrade_test.py::test_fix_fstrings_noop[(] tests/pyupgrade_test.py::test_fix_fstrings_noop["{}" tests/pyupgrade_test.py::test_fix_fstrings_noop["{}".format(\n tests/pyupgrade_test.py::test_fix_fstrings_noop["{} tests/pyupgrade_test.py::test_fix_fstrings_noop["{foo} tests/pyupgrade_test.py::test_fix_fstrings_noop["{0} tests/pyupgrade_test.py::test_fix_fstrings_noop["{x} tests/pyupgrade_test.py::test_fix_fstrings_noop["{x.y} tests/pyupgrade_test.py::test_fix_fstrings_noop[b"{} tests/pyupgrade_test.py::test_fix_fstrings_noop["{:{}}".format(x, tests/pyupgrade_test.py::test_fix_fstrings_noop["{a[b]}".format(a=a)] tests/pyupgrade_test.py::test_fix_fstrings_noop["{a.a[b]}".format(a=a)] tests/pyupgrade_test.py::test_fix_fstrings["{} tests/pyupgrade_test.py::test_fix_fstrings["{1} tests/pyupgrade_test.py::test_fix_fstrings["{x.y}".format(x=z)-f"{z.y}"] tests/pyupgrade_test.py::test_fix_fstrings["{.x} tests/pyupgrade_test.py::test_fix_fstrings["hello tests/pyupgrade_test.py::test_fix_fstrings["{}{{}}{}".format(escaped, tests/pyupgrade_test.py::test_main_trivial tests/pyupgrade_test.py::test_main_noop tests/pyupgrade_test.py::test_main_changes_a_file tests/pyupgrade_test.py::test_main_keeps_line_endings tests/pyupgrade_test.py::test_main_syntax_error tests/pyupgrade_test.py::test_main_non_utf8_bytes tests/pyupgrade_test.py::test_keep_percent_format tests/pyupgrade_test.py::test_py3_plus_argument_unicode_literals tests/pyupgrade_test.py::test_py3_plus_super tests/pyupgrade_test.py::test_py3_plus_new_style_classes tests/pyupgrade_test.py::test_py36_plus_fstrings tests/pyupgrade_test.py::test_noop_token_error