ruff/crates/ruff_python_formatter/src/expression
Charlie Marsh f2939c678b
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
2023-08-11 13:33:15 +00:00
..
expr_attribute.rs Avoid breaking call chains unnecessarily (#6488) 2023-08-11 13:33:15 +00:00
expr_await.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
expr_bin_op.rs Call chain formatting in fluent style (#6151) 2023-08-04 13:58:01 +00:00
expr_bool_op.rs Fix formatting of chained boolean operations (#6394) 2023-08-07 12:22:33 -05:00
expr_call.rs Call chain formatting in fluent style (#6151) 2023-08-04 13:58:01 +00:00
expr_compare.rs Replace Formatter<PyFormatContext<'_>> with PyFormatter (#6330) 2023-08-04 10:48:58 +02:00
expr_constant.rs Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
expr_dict.rs Move empty_parenthesized into the parentheses.rs (#6403) 2023-08-08 19:17:17 +00:00
expr_dict_comp.rs Add a with_dangling_comments to the parenthesized formatter (#6402) 2023-08-07 19:12:12 +00:00
expr_f_string.rs Rename JoinedStr to FString in the AST (#6379) 2023-08-07 17:33:17 +00:00
expr_formatted_value.rs Track formatting all comments 2023-08-10 09:19:27 +02:00
expr_generator_exp.rs Add a with_dangling_comments to the parenthesized formatter (#6402) 2023-08-07 19:12:12 +00:00
expr_if_exp.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
expr_ipy_escape_command.rs Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
expr_lambda.rs Fix formatting of lambda star arguments (#6257) 2023-08-02 19:31:20 +00:00
expr_list.rs Move empty_parenthesized into the parentheses.rs (#6403) 2023-08-08 19:17:17 +00:00
expr_list_comp.rs Add a with_dangling_comments to the parenthesized formatter (#6402) 2023-08-07 19:12:12 +00:00
expr_name.rs Remove Parse trait (#6235) 2023-08-01 18:35:03 +02:00
expr_named_expr.rs Force parentheses for named expressions in more contexts (#6494) 2023-08-11 01:54:46 -04:00
expr_set.rs Add a with_dangling_comments to the parenthesized formatter (#6402) 2023-08-07 19:12:12 +00:00
expr_set_comp.rs Add a with_dangling_comments to the parenthesized formatter (#6402) 2023-08-07 19:12:12 +00:00
expr_slice.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
expr_starred.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
expr_subscript.rs Call chain formatting in fluent style (#6151) 2023-08-04 13:58:01 +00:00
expr_tuple.rs Move empty_parenthesized into the parentheses.rs (#6403) 2023-08-08 19:17:17 +00:00
expr_unary_op.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
expr_yield.rs Replace Formatter<PyFormatContext<'_>> with PyFormatter (#6330) 2023-08-04 10:48:58 +02:00
expr_yield_from.rs Add AnyExpressionYield to consolidate ExprYield and ExprYieldFrom (#6127) 2023-07-27 16:01:16 +00:00
mod.rs Rename Magic* to IpyEscape* (#6395) 2023-08-09 13:28:18 +00:00
number.rs Replace Formatter<PyFormatContext<'_>> with PyFormatter (#6330) 2023-08-04 10:48:58 +02:00
parentheses.rs Move empty_parenthesized into the parentheses.rs (#6403) 2023-08-08 19:17:17 +00:00
string.rs Rename JoinedStr to FString in the AST (#6379) 2023-08-07 17:33:17 +00:00