ruff/crates/ruff_python_formatter/src/expression
Charlie Marsh 22770fb4be
Avoid extra parentheses in await expressions (#7424)
## Summary

This PR aligns the await parenthesizing with the unary case, which is:
if the value is already parenthesized, avoid parenthesizing; otherwise,
only parenthesize if the _value_ needs parenthesizing.

Closes https://github.com/astral-sh/ruff/issues/7420.

## Test Plan

`cargo test`

No change in similarity.

Before:

| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1632 |
| django | 0.99982 | 2760 | 37 |
| transformers | 0.99957 | 2587 | 399 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99983 | 3496 | 18 |
| warehouse | 0.99923 | 648 | 18 |
| zulip | 0.99962 | 1437 | 22 |

After:

| project | similarity index | total files | changed files |

|--------------|------------------:|------------------:|------------------:|
| cpython | 0.76083 | 1789 | 1632 |
| django | 0.99982 | 2760 | 37 |
| transformers | 0.99957 | 2587 | 399 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99983 | 3496 | 18 |
| warehouse | 0.99923 | 648 | 18 |
| zulip | 0.99962 | 1437 | 22 |
2023-09-16 13:10:35 -04:00
..
binary_like.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
expr_attribute.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
expr_await.rs Avoid extra parentheses in await expressions (#7424) 2023-09-16 13:10:35 -04:00
expr_bin_op.rs Bool expression comment placement (#7269) 2023-09-12 06:39:57 +00:00
expr_bool_op.rs Bool expression comment placement (#7269) 2023-09-12 06:39:57 +00:00
expr_call.rs Fix build (#7437) 2023-09-16 14:50:36 +00:00
expr_compare.rs Bool expression comment placement (#7269) 2023-09-12 06:39:57 +00:00
expr_constant.rs Move ExprConstant::kind to StringConstant::unicode (#7180) 2023-09-06 07:39:25 +00:00
expr_dict.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_dict_comp.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_f_string.rs Use the formatter prelude in more files (#6882) 2023-08-25 16:51:07 -04:00
expr_formatted_value.rs Use the formatter prelude in more files (#6882) 2023-08-25 16:51:07 -04:00
expr_generator_exp.rs Preserve generator parentheses in single argument call expressions (#7226) 2023-09-08 10:53:34 +02:00
expr_if_exp.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
expr_ipy_escape_command.rs Memoize text width (#6552) 2023-09-06 07:10:13 +00:00
expr_lambda.rs Fix inconsistent expr_lambda formatting (#6318) 2023-09-08 09:40:58 +00:00
expr_list.rs Move Ranged into ruff_text_size (#6919) 2023-08-27 14:12:51 -04:00
expr_list_comp.rs Use the formatter prelude in more files (#6882) 2023-08-25 16:51:07 -04:00
expr_name.rs Memoize text width (#6552) 2023-09-06 07:10:13 +00:00
expr_named_expr.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_set.rs Move Ranged into ruff_text_size (#6919) 2023-08-27 14:12:51 -04:00
expr_set_comp.rs Use the formatter prelude in more files (#6882) 2023-08-25 16:51:07 -04:00
expr_slice.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_starred.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_subscript.rs Fix build (#7437) 2023-09-16 14:50:36 +00:00
expr_tuple.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_unary_op.rs Avoid extra parentheses in unary expressions (#7428) 2023-09-16 13:07:38 -04:00
expr_yield.rs Introduce Token element (#7048) 2023-09-02 10:05:47 +02:00
expr_yield_from.rs Use the formatter prelude in more files (#6882) 2023-08-25 16:51:07 -04:00
mod.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
number.rs Memoize text width (#6552) 2023-09-06 07:10:13 +00:00
operator.rs Split implicit concatenated strings before binary expressions (#7145) 2023-09-08 06:51:26 +00:00
parentheses.rs Use CommentRanges in backwards lexing (#7360) 2023-09-16 03:21:45 +00:00
string.rs Introduce IndentWidth (#7301) 2023-09-13 14:52:24 +02:00