mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[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:
parent
62075afe4f
commit
dc5e922221
3 changed files with 122 additions and 27 deletions
|
@ -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)]
|
||||
))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue