Charlie Marsh
1880cceac1
Avoid extra parentheses in unary expressions (#7428)
## Summary
This PR applies a similar fix to unary expressions as in
https://github.com/astral-sh/ruff/pull/7424. Specifically, we only need
to parenthesize the entire operator if the operand itself doesn't have
parentheses, and requires parentheses.
Closes https://github.com/astral-sh/ruff/issues/7423.
## 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:07:38 -04:00
..
2023-09-16 14:50:36 +00:00
2023-09-16 13:07:38 -04:00
2023-09-11 08:03:59 +00:00
2023-09-13 09:01:49 +00:00
2023-09-16 03:21:45 +00:00
2023-07-18 18:27:46 +00:00
2023-09-16 03:21:45 +00:00
2023-09-02 10:05:47 +02:00
2023-09-02 10:05:47 +02:00
2023-09-08 09:25:06 +00:00
2023-08-11 10:41:48 +00:00
2023-08-26 14:45:44 +00:00
2023-09-16 16:21:45 +02:00
2023-08-04 11:52:26 +00:00
2023-09-13 14:52:24 +02:00
2023-06-20 16:49:21 +00:00
2023-09-06 07:10:13 +00:00