-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Prevent wrapping of multiline fstrings in parens #4325
Conversation
The one other edge case in the issue is also likely around this function: Line 276 in 551ede2
I'm seeing if that's a small fix that can go in the same PR. |
^ So that other edge case is not related to #3822, as I'm able to reproduce it even on black v24.4.0: $ black --version
black, 24.4.0 (compiled: yes)
Python (CPython) 3.12.2
$ cat asd.py
log(
f"Received operation {server_operation.name} from "
f"{self.writer._transport.get_extra_info('peername')}", # type: ignore[attr-defined]
)
$ black asd.py
reformatted asd.py
All done! ✨ 🍰 ✨
1 file reformatted.
$ cat asd.py
log(
f"Received operation {server_operation.name} from {self.writer._transport.get_extra_info('peername')}", # type: ignore[attr-defined]
) cc @hauntsaninja, does that seem right? |
No, that doesn't seem right. Make sure you're not getting fooled by
|
And sorry for not fully minimising it, e.g. this repros without
|
Thanks for clarification, both cases should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thank you for the fixes (and thank you again for the original feature)!
(also confirmed this commit is clean on my current work codebase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Resolves #4324
Description
The function
is_multiline_string
was only being run forLeaf
nodes, but in that context, multiline f-strings should also have been respected. The code has been adjusted to respect f-strings as well.The
STRING
leaves created byfstring_to_string
were also missinglineno
fields which are used in parts of the codebase.