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
Intentional call chain with explicit parenthesis not respected #3100
Comments
I'm inclined to keep the current behavior. Black generally tries to put things in one line where possible. |
To perhaps paraphrase the argument, this is the call chain equivalent of the magic trailing comma The problem is that call-chaining with periods at the end of the line, which is legal python, breaks for the final trailing period: (
numpy.
array([3])
) # works
(
numpy.
array([3]).
) # SyntaxError So the only way to tell (
wont()
.get()
.collapsed()
.unless()
.some_lines()
.are_deleted()
) vs (
intentionally().
left().
expanded()
) |
I agree with Jelle, we don't want to take previous formatting into account any more than is absolutely necessary. Introducing another magic trailing comma does not sound good. |
With the maintainer rejection, I'll close this issue now. |
Couldn't the explicit parenthesis be like the trailing comma? This: (intentionally().left().expanded()) would format to: (
intentionally()
.left()
.expanded()
) While something like this, without outer parenthesis, intentionally(
).left(
).expanded() would format to: intentionally().left().expanded() (if it fits in one line, of course) In this case, the one line form is quite readable. But when we start to include parameters which are calls to other functions, it starts to get unreadable in one line: intentionally(arg=func(x=1, y=2)).left(arg=f(3)).expanded() |
Describe the bug
this becomes
this.
To Reproduce
Run above code with these arguments:
Expected behavior
intentional parenthesis around method chains should be respected and not break into single statement.
Environment
Additional context
The text was updated successfully, but these errors were encountered: