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

Rewriting six.raise_from breaks with multiline args #359

Closed
hugovk opened this issue Nov 10, 2020 · 3 comments
Closed

Rewriting six.raise_from breaks with multiline args #359

hugovk opened this issue Nov 10, 2020 · 3 comments
Labels

Comments

@hugovk
Copy link
Contributor

hugovk commented Nov 10, 2020

pyupgrade==2.7.3

Running pyupgrade 1.py --py3-plus

With Black magic comma

Before

import six

six.raise_from(
    ValueError("a long error message which makes Black add a magic comma after None"),
    None,
)

After

syntax error:

import six

raise ValueError("a long error message which makes Black add a magic comma after None") from 
    None,

Without Black magic comma

Before

import six

six.raise_from(
    ValueError("a long error message which makes Black add a magic comma after None"),
    None
)

After

syntax error:

import six

raise ValueError("a long error message which makes Black add a magic comma after None") from 
    None

Both args on same line

Before

import six

six.raise_from(
    ValueError("a long error message which makes Black add a magic comma after None"), None
)

After

Now it's okay:

import six

raise ValueError("a long error message which makes Black add a magic comma after None") from None
@asottile asottile added the bug label Nov 10, 2020
@asottile
Copy link
Owner

probably the "best" way to fix this is with backslash insertion, as ugly as it is

@hugovk
Copy link
Contributor Author

hugovk commented Nov 10, 2020

In this particular case, Black's multilines triggered the bug, and to atone will happily mop up any ugly backslashes afterwards :)

Repository owner deleted a comment Jun 16, 2021
@asottile
Copy link
Owner

via #361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants