mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
Add formatting for StmtMatch
(#6286)
## Summary This PR adds support for `StmtMatch` with subs for `MatchCase`. ## Test Plan Add a few additional test cases around `match` statement, comments, line breaks. resolves: #6298
This commit is contained in:
parent
87984e9ac7
commit
001aa486df
12 changed files with 882 additions and 444 deletions
57
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py
vendored
Normal file
57
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
# leading match comment
|
||||
match foo: # dangling match comment
|
||||
case "bar":
|
||||
pass
|
||||
|
||||
|
||||
# leading match comment
|
||||
match ( # leading expr comment
|
||||
# another leading expr comment
|
||||
foo # trailing expr comment
|
||||
# another trailing expr comment
|
||||
): # dangling match comment
|
||||
case "bar":
|
||||
pass
|
||||
|
||||
|
||||
# leading match comment
|
||||
match ( # hello
|
||||
foo # trailing expr comment
|
||||
, # another
|
||||
): # dangling match comment
|
||||
case "bar":
|
||||
pass
|
||||
|
||||
|
||||
match [ # comment
|
||||
first,
|
||||
second,
|
||||
third
|
||||
]: # another comment
|
||||
case ["a", "b", "c"]:
|
||||
pass
|
||||
|
||||
match ( # comment
|
||||
"a b c"
|
||||
).split(): # another comment
|
||||
case ["a", "b", "c"]:
|
||||
pass
|
||||
|
||||
|
||||
match ( # comment
|
||||
# let's go
|
||||
yield foo
|
||||
): # another comment
|
||||
case ["a", "b", "c"]:
|
||||
pass
|
||||
|
||||
|
||||
match aaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh: # comment
|
||||
case "sshhhhhhhh":
|
||||
pass
|
||||
|
||||
|
||||
def foo():
|
||||
match inside_func: # comment
|
||||
case "bar":
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue