Repository: asottile/pyupgrade

Issue:
exception stack trace is replaced by a bare `raise`
With python 3.7.4, the formatted exception stack trace will be replaced by a bare `raise`, and then make a syntax error.

But the strange thing is that this occurs only when the statement is executed in the pre-commit hook of git, the replacement disappears if the statement is executed directly.

```python
poetry run pyupgrade --py37-plus
```

- Before
 
```python
async def general_exception_handler(request: Request, exc: Exception):
    return JSONResponse(
        status_code=HTTP_500_INTERNAL_SERVER_ERROR,
        content={
            'request': f'{request.method} {request.url}',
            'message': str(exc),
            'detail': jsonable_encoder(traceback.format_exception(*sys.exc_info())),
        },
    )
```

- After

```python
async def general_exception_handler(request: Request, exc: Exception):
    return JSONResponse(
        status_code=HTTP_500_INTERNAL_SERVER_ERROR,
        content={
            'request': f'{request.method} {request.url}',
            'message': str(exc),
            # the exception stack info is replaced by a bare `raise`
            'detail': jsonable_encoder(raise),
        },
    )
```


Discussion:

Patch:
diff --git a/pyupgrade.py b/pyupgrade.py
index 54bbe0d..8b47463 100644
--- a/pyupgrade.py
+++ b/pyupgrade.py
@@ -1558,7 +1558,7 @@ class FindPy3Plus(ast.NodeVisitor):
         elif (
                 isinstance(self._previous_node, ast.Expr) and
                 self._is_six(node.func, ('reraise',)) and
-                not _starargs(node) or self._is_star_sys_exc_info(node)
+                (not _starargs(node) or self._is_star_sys_exc_info(node))
         ):
             self.six_reraise.add(_ast_to_offset(node))
         elif (


Test patch:
diff --git a/tests/six_test.py b/tests/six_test.py
index 0a973c0..9ddffd7 100644
--- a/tests/six_test.py
+++ b/tests/six_test.py
@@ -41,6 +41,7 @@ from pyupgrade import _fix_py3_plus
             'isinstance("foo", text_type)\n',
             id='relative import might not be six',
         ),
+        ('traceback.format_exc(*sys.exc_info())'),
     ),
 )
 def test_fix_six_noop(s):