mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Improve comment handling around PatternMatchAs
(#6797)
## Summary Follows up on https://github.com/astral-sh/ruff/pull/6652#discussion_r1300871033 with some modifications to the `PatternMatchAs` comment handling. Specifically, any comments between the `as` and the end are now formatted as dangling, and we now insert some newlines in the appropriate places. ## Test Plan `cargo test`
This commit is contained in:
parent
d08f697a04
commit
1e6d1182bf
4 changed files with 142 additions and 7 deletions
|
@ -174,6 +174,27 @@ match pattern_comments:
|
|||
pass
|
||||
|
||||
|
||||
match pattern_comments:
|
||||
case (
|
||||
pattern
|
||||
# 1
|
||||
as
|
||||
# 2
|
||||
name
|
||||
# 3
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match subject:
|
||||
case (
|
||||
pattern # 1
|
||||
as # 2
|
||||
name # 3
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match x:
|
||||
case (a as b) as c:
|
||||
pass
|
||||
|
@ -378,10 +399,11 @@ match pattern_comments:
|
|||
match pattern_comments:
|
||||
case (
|
||||
# 1
|
||||
pattern as name # 2
|
||||
pattern # 2
|
||||
# 3
|
||||
# 4
|
||||
# 5 # 6
|
||||
as # 4
|
||||
# 5
|
||||
name # 6
|
||||
# 7
|
||||
):
|
||||
pass
|
||||
|
@ -389,15 +411,37 @@ match pattern_comments:
|
|||
|
||||
match pattern_comments:
|
||||
case (
|
||||
pattern as name
|
||||
pattern
|
||||
# 1
|
||||
# 2
|
||||
# 3 # 4
|
||||
as # 2
|
||||
# 3
|
||||
name # 4
|
||||
# 5
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match pattern_comments:
|
||||
case (
|
||||
pattern
|
||||
# 1
|
||||
as
|
||||
# 2
|
||||
name
|
||||
# 3
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match subject:
|
||||
case (
|
||||
pattern # 1
|
||||
as # 2
|
||||
name # 3
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
match x:
|
||||
case (a as b) as c:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue