Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix raise_from with multi lines / trailing comma #361

Merged
merged 1 commit into from Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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