Intentional call chain with explicit parenthesis not respected
See original GitHub issueDescribe the bug
return (
flu(files)
.map(to_path)
.flatten()
.collect() # type: ignore
)
this becomes
return flu(files).map(to_path).flatten().collect() # type: ignore
this.
To Reproduce Run above code with these arguments:
$ black --target-version py310 -- test.py
Expected behavior
intentional parenthesis around method chains should be respected and not break into single statement.
Environment
- Black’s version: main
- OS and Python version: Linux/Python 3.10.4
Additional context
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Should I fully parenthesize expressions or rely on precedence ...
Yes. You should always use parentheses... you do not control the order of precedence... the ...
Read more >Ambiguous PEMDAS - Harvard Mathematics Department
"If no parentheses are present, multiply and divide before adding and subtracting." This is a very rough rule but it has the advantage...
Read more >method call without parenthesis doesn't forward all arguments ...
I need to understand why sometimes when a method call is made with parenthesis to initialize a base class, for instance, it doesn't...
Read more >Expressions and Control Structures - Solidity
Calling the function g via either way results in it being called “externally”, using a message call and not directly via jumps. Please...
Read more >PSR-12: Extended Coding Style - PHP-FIG
When instantiating a new class, parentheses MUST always be present even when there are no arguments passed to the constructor. new Foo();. 4.1...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m inclined to keep the current behavior. Black generally tries to put things in one line where possible.
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.