Handle bracketed comments on sequence patterns (#6801)

## Summary

This PR ensures that we handle bracketed comments on sequences, like `#
comment` here:

```python
match x:
    case [ # comment
        1, 2
    ]:
        pass
```

The handling is very similar to other, similar nodes, except that we do
need some special logic to determine whether the sequence is
parenthesized, similar to our logic for tuples.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-08-25 00:03:27 -04:00 committed by GitHub
parent 474e8fbcd4
commit f754ad5898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 32 deletions

View file

@ -572,8 +572,7 @@ match foo:
match foo:
case [
# leading
case [ # leading
# leading
# leading
# leading
@ -685,9 +684,8 @@ match foo:
2,
]:
pass
case [
( # outer
# inner
case [ # outer
( # inner
1
),
2,
@ -695,29 +693,25 @@ match foo:
pass
case [
( # outer
[
# inner
[ # inner
1,
]
)
]:
pass
case [
( # outer
# inner outer
[
# inner
case [ # outer
( # inner outer
[ # inner
1,
]
)
]:
pass
case [
( # outer
case [ # outer
(
# own line
# inner outer
[
# inner
[ # inner
1,
]
)