Skip over parentheses when detecting in keyword (#8054)

## Summary

Given an expression like `[x for (x) in y]`, we weren't skipping over
parentheses when searching for the `in` between `(x)` and `y`.

Closes https://github.com/astral-sh/ruff/issues/8053.
This commit is contained in:
Charlie Marsh 2023-10-18 19:13:58 -04:00 committed by GitHub
parent b2d1fcf7b2
commit 2729c4cacd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 20 deletions

View file

@ -108,6 +108,9 @@ aaaaaaaaaaaaaaaaaaaaa = [
c # negative decimal
]
# Parenthesized targets and iterators.
[x for (x) in y]
[x for x in (y)]
```
## Output
@ -247,6 +250,10 @@ aaaaaaaaaaaaaaaaaaaaa = [
for components in b # pylint: disable=undefined-loop-variable # integer 1 may only have decimal 01-09
+ c # negative decimal
]
# Parenthesized targets and iterators.
[x for (x) in y]
[x for x in (y)]
```