Avoid marking inner-parenthesized comments as dangling bracket comments (#6517)

## Summary

The bracketed-end-of-line comment rule is meant to assign comments like
this as "immediately following the bracket":

```python
f(  # comment
    1
)
```

However, the logic was such that we treated this equivalently:

```python
f(
    (  # comment
        1
    )
)
```

This PR modifies the placement logic to ensure that we only skip the
opening bracket, and not any nested brackets. The above is now formatted
as:

```python
f(
    (
        # comment
        1
    )
)
```

(But will be corrected once we handle parenthesized comments properly.)

## Test Plan

`cargo test`

Confirmed no change in similarity score.
This commit is contained in:
Charlie Marsh
2023-08-14 09:52:19 -04:00
committed by GitHub
parent f16e780e0a
commit 40407dcce5
3 changed files with 32 additions and 7 deletions

View File

@@ -115,3 +115,9 @@ f (
threshold_date = datetime.datetime.now() - datetime.timedelta( # comment
days=threshold_days_threshold_days
)
f(
( # comment
1
)
)