yapf formats long call chains with weird spacing
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
Take the following lengthy call chain
```python
def some_function(session):
result = (session.query(models.Employee.id).filter(models.Employee.business_id == unique_id).filter(models.Employee.age > 25).order_by(models.Employee.id.asc()).all())
```
I'm would love an output that looked something like this:
```python
def some_function(session):
result = (
session.query(models.Employee.id)
.filter(models.Employee.business_id == unique_id)
.filter(models.Employee.age > 25)
.order_by(models.Employee.id.asc())
.all()
)
```
But instead yapf is doing this:
```python
def some_function(session):
result = (
session.query(models.Employee.id
).filter(models.Employee.business_id == unique_id
).filter(models.Employee.age > 25
).order_by(models.Employee.id.asc()
).all()
)
```
I've tried everything I can think of
- CONTINUATION_ALIGN_STYLE
- SPLIT_BEFORE_DOT
- SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN
- Adjusting the SPLIT_PENALTY_AFTER_OPENING_BRACKET value
It wouldn't be so bad if it didn't change my formatting from that second code block to the third. Right now the only thing I can think of is to either wrap the blocks with `#yapf: disable` tags or to use back slashes, both of which I'm pretty against.
`yapf==0.24.0`
Contributor guide
Assessment
This issue has not been assessed yet.