mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 12:25:10 +00:00
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:
parent
474e8fbcd4
commit
f754ad5898
3 changed files with 93 additions and 32 deletions
|
|
@ -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,
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue