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:
Charlie Marsh 2023-08-23 00:48:20 -04:00 committed by GitHub
parent d08f697a04
commit 1e6d1182bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 142 additions and 7 deletions

View file

@ -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