Charlie Marsh
95702e408f
Respect parenthesized generators in has_own_parentheses (#8100)
## Summary
When analyzing:
```python
if "root" not in (
long_tree_name_tree.split("/")[0]
for long_tree_name_tree in really_really_long_variable_name
):
msg = "Could not find root. Please try a different forest."
raise ValueError(msg)
```
We missed that the generator expression is parenthesized, because the
parentheses are _part_ of the generator -- so
`is_expression_parenthesized` returns `False`. We needed to take into
account that generators and tuples may or may not be parenthesized when
determining whether we can omit parentheses while splitting an
expression.
Closes https://github.com/astral-sh/ruff/issues/8090.
## Test Plan
No changes in similarity.
Before:
| project | similarity index | total files | changed files |
|----------------|------------------:|------------------:|------------------:|
| cpython | 0.75803 | 1799 | 1647 |
| django | 0.99983 | 2772 | 34 |
| home-assistant | 0.99953 | 10596 | 186 |
| poetry | 0.99891 | 317 | 17 |
| transformers | 0.99966 | 2657 | 330 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99978 | 3669 | 20 |
| warehouse | 0.99977 | 654 | 13 |
| zulip | 0.99970 | 1459 | 22 |
After:
| project | similarity index | total files | changed files |
|----------------|------------------:|------------------:|------------------:|
| cpython | 0.75803 | 1799 | 1647 |
| django | 0.99983 | 2772 | 34 |
| home-assistant | 0.99953 | 10596 | 186 |
| poetry | 0.99891 | 317 | 17 |
| transformers | 0.99966 | 2657 | 330 |
| twine | 1.00000 | 33 | 0 |
| typeshed | 0.99978 | 3669 | 20 |
| warehouse | 0.99977 | 654 | 13 |
| zulip | 0.99970 | 1459 | 22 |
2023-10-22 19:58:25 -04:00
..
2023-10-19 20:49:53 +00:00
2023-10-02 09:49:59 -04:00
2023-09-21 08:01:24 +02:00
2023-10-20 14:07:41 -05:00
2023-10-20 23:08:26 +00:00
2023-10-10 20:04:21 +00:00
2023-10-19 09:24:11 +00:00
2023-07-04 14:27:23 +00:00
2023-10-22 10:03:36 -04:00
2023-10-20 00:12:27 +00:00
2023-10-13 01:06:02 +00:00
2023-10-19 17:50:45 +00:00
2023-09-29 02:55:39 +00:00
2023-10-22 19:58:25 -04:00
2023-09-29 02:55:39 +00:00
2023-09-25 15:13:21 +00:00
2023-10-09 10:11:08 +00:00
2023-08-01 19:29:42 +02:00
2023-10-19 19:15:54 -04:00
2023-10-08 14:49:45 +00:00
2023-09-28 18:55:19 +00:00
2023-10-19 20:49:53 +00:00
2023-10-13 01:06:02 +00:00
2023-08-28 06:44:56 +00:00
2023-10-18 01:15:25 +00:00
2023-10-20 00:25:32 +00:00