Black should chop down long call chains which are not in an assignment
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 41.8k
- Forks
- 2.9k
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 9
Description
Black chops down long call chains which are assigned to a variable:
built = SomeBuilder().with_something("").with_something("").with_something("").with_something("").with_something("").with_something("").build()
is changed into
built = (
SomeBuilder()
.with_something("")
.with_something("")
.with_something("")
.with_something("")
.with_something("")
.with_something("")
.build()
)
However, the result is ugly and inconsistent if the result is not assigned to anything:
SomeBuilder().with_something("").with_something("").with_something("").with_something("").with_something("").with_something("").build()
is changed into
SomeBuilder().with_something("").with_something(
""
).with_something("").with_something("").with_something(
""
).with_something(
""
).build()
Operating system: Ubuntu 18.04
Python version: Python 3.6.7
Black version: black, version 18.9b0
Does also happen on master: Yes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the assigned and unassigned call-chain examples with the reported Black version, then trace the formatter entry point that handles long chained calls. Done means an unassigned chain is split consistently with the assigned example without regressing existing formatting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100