mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 20:31:57 +00:00
Avoid searching for bracketed comments in unparenthesized generators (#7627)
Similar to tuples, a generator _can_ be parenthesized or unparenthesized. Only search for bracketed comments if it contains its own parentheses. Closes https://github.com/astral-sh/ruff/issues/7623.
This commit is contained in:
parent
1a22eae98c
commit
865c89800e
5 changed files with 66 additions and 7 deletions
|
|
@ -58,6 +58,23 @@ a = (
|
|||
aaaaaaaaaaaaaaaaaaaaa = (
|
||||
o for o in self.registry.values if o.__class__ is not ModelAdmin
|
||||
)
|
||||
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7623
|
||||
tuple(
|
||||
0 # comment
|
||||
for x in y
|
||||
)
|
||||
|
||||
tuple(
|
||||
(0 # comment
|
||||
for x in y)
|
||||
)
|
||||
|
||||
tuple(
|
||||
( # comment
|
||||
0 for x in y
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
|
@ -122,6 +139,25 @@ a = (
|
|||
aaaaaaaaaaaaaaaaaaaaa = (
|
||||
o for o in self.registry.values if o.__class__ is not ModelAdmin
|
||||
)
|
||||
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7623
|
||||
tuple(
|
||||
0 # comment
|
||||
for x in y
|
||||
)
|
||||
|
||||
tuple(
|
||||
(
|
||||
0 # comment
|
||||
for x in y
|
||||
)
|
||||
)
|
||||
|
||||
tuple(
|
||||
( # comment
|
||||
0 for x in y
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue