Skip to content

Commit

Permalink
Merge pull request #361 from asottile/invalid_reraise_from_multiline
Browse files Browse the repository at this point in the history
fix raise_from with multi lines / trailing comma
  • Loading branch information
asottile committed Sep 25, 2021
2 parents 79d8df8 + 4436b63 commit 4130821
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/six_calls.py
Expand Up @@ -51,7 +51,7 @@
'assertRegex': '{args[0]}.assertRegex({rest})',
}
SIX_INT2BYTE_TMPL = 'bytes(({args[0]},))'
RAISE_FROM_TMPL = 'raise {args[0]} from {rest}'
RAISE_FROM_TMPL = 'raise {args[0]} from {args[1]}'
RERAISE_TMPL = 'raise'
RERAISE_2_TMPL = 'raise {args[1]}.with_traceback(None)'
RERAISE_3_TMPL = 'raise {args[1]}.with_traceback({args[2]})'
Expand Down
10 changes: 10 additions & 0 deletions tests/features/six_test.py
Expand Up @@ -126,6 +126,16 @@ def test_fix_six_noop(s):
'six.raise_from(exc, exc_from)\n',
'raise exc from exc_from\n',
),
pytest.param(
'six.raise_from(\n'
' e,\n'
' f,\n'
')',
'raise e from f',
id='six raise_from across multiple lines',
),
(
'six.reraise(tp, exc, tb)\n',
'raise exc.with_traceback(tb)\n',
Expand Down

0 comments on commit 4130821

Please sign in to comment.