Fix find_only_token_in_range with expression parentheses (#5645)

## Summary

Fix an oversight in `find_only_token_in_range` where the following code
would panic due do the closing and opening parentheses being in the
range we scan:
```python
d1 = [
    ("a") if # 1
    ("b") else # 2
    ("c")
]
```
Closing and opening parentheses respectively are now correctly skipped.

## Test Plan

I added a regression test
This commit is contained in:
konsti 2023-07-10 15:55:19 +02:00 committed by GitHub
parent 82317ba1fd
commit cab3a507bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View file

@ -31,3 +31,11 @@ c2 = (
# 8
"b" # 9
)
# regression test: parentheses outside the expression ranges interfering with finding
# the `if` and `else` token finding
d1 = [
("a") if # 1
("b") else # 2
("c")
]