mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 12:25:10 +00:00
Avoid breaking call chains unnecessarily (#6488)
## Summary
This PR attempts to fix the formatting of the following expression:
```python
max_message_id = (
Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id
)
```
Specifically, Black preserves _that_ formatting, while we do:
```python
max_message_id = (
Message.objects.filter(recipient=recipient)
.order_by("id")
.reverse()[0]
.id
)
```
The fix here is to add a group around the entire call chain.
## Test Plan
Before:
- `zulip`: 0.99702
- `django`: 0.99784
- `warehouse`: 0.99585
- `build`: 0.75623
- `transformers`: 0.99470
- `cpython`: 0.75989
- `typeshed`: 0.74853
After:
- `zulip`: 0.99703
- `django`: 0.99791
- `warehouse`: 0.99586
- `build`: 0.75623
- `transformers`: 0.99470
- `cpython`: 0.75989
- `typeshed`: 0.74853
This commit is contained in:
parent
b05574babd
commit
f2939c678b
3 changed files with 122 additions and 91 deletions
|
|
@ -160,7 +160,13 @@ zero(
|
|||
five,
|
||||
)
|
||||
|
||||
max_message_id = (
|
||||
Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id
|
||||
)
|
||||
|
||||
max_message_id = (
|
||||
Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id()
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
|
@ -334,6 +340,14 @@ zero(
|
|||
).four(
|
||||
five,
|
||||
)
|
||||
|
||||
max_message_id = (
|
||||
Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id
|
||||
)
|
||||
|
||||
max_message_id = (
|
||||
Message.objects.filter(recipient=recipient).order_by("id").reverse()[0].id()
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue