Open tjkuson opened 1 year ago
Behaviour is the same for long method chains.
Input:
if True:
if True:
if True:
if True:
if foo == some.very.very.very.very.very.very.very.very.long_function_name(
bar
):
pass
Output:
if True:
if True:
if True:
if True:
if (
foo
== some.very.very.very.very.very.very.very.very.long_function_name(
bar
)
):
pass
EDIT: I marked this as outdated as the revised reproduction in the original post now details this behaviour.
I see the same behavior in Black, or am I misunderstanding?
Sorry, I made an error in the reproduction!
Input:
if True:
if True:
if True:
if True:
if foo := some.very.very.very.very.very.very.very.very.very.long.function(
search.study_id
):
pass
Ruff
if True:
if True:
if True:
if True:
if (
foo
:= some.very.very.very.very.very.very.very.very.very.long.function(
search.study_id
)
):
pass
Black
if True:
if True:
if True:
if True:
if foo := some.very.very.very.very.very.very.very.very.very.long.function(
search.study_id
):
pass
(I've updated the original post to include the proper reproduction.)
It seems that black formats the walrus operator more closely to assignments where it only breaks the right but never the left (or before/after the operator), even if doing so would help fitting the content on the line.
This seems similar to #7246 which was closed as completed, but reproducible in the latest
0.1.4
release.Input:
Ruff formatter output:
Black doesn't make any changes to the input file.
Ruff playground