Prevent wrapping of multiline fstrings in parens#4325
Prevent wrapping of multiline fstrings in parens#4325JelleZijlstra merged 7 commits intopsf:mainfrom
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. |
hauntsaninja
left a comment
There was a problem hiding this comment.
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) |
Resolves #4324
Description
The function
is_multiline_stringwas only being run forLeafnodes, but in that context, multiline f-strings should also have been respected. The code has been adjusted to respect f-strings as well.The
STRINGleaves created byfstring_to_stringwere also missinglinenofields which are used in parts of the codebase.