[flake8-comprehensions] Handle extraneous parentheses around list comprehension (C403) (#15877)

## Summary

Given the following code:

```python
set(([x for x in range(5)]))
```

the current implementation of C403 results in

```python
{(x for x in range(5))}
```

which is a set containing a generator rather than the result of the
generator.

This change removes the extraneous parentheses so that the resulting
code is:

```python
{x for x in range(5)}
```


## Test Plan

`cargo nextest run` and `cargo insta test`
This commit is contained in:
Justin Bramley 2025-02-03 13:26:03 -05:00 committed by GitHub
parent 62075afe4f
commit dc5e922221
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 122 additions and 27 deletions

View file

@ -21,3 +21,14 @@ s = set( # comment
s = set([ # comment
x for x in range(3)
])
s = set(([x for x in range(3)]))
s = set(((([x for x in range(3)]))))
s = set( # outer set comment
( # inner paren comment - not preserved
((
[ # comprehension comment
x for x in range(3)]
))))