-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73a6595
commit a755afe
Showing
3 changed files
with
185 additions
and
2 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
crates/ruff_python_formatter/tests/snapshots/format@statement__match.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py | ||
--- | ||
## Input | ||
```py | ||
# 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 | ||
``` | ||
|
||
## Output | ||
```py | ||
# leading match comment | ||
match foo: # dangling match comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
# leading match comment | ||
match ( | ||
# leading expr comment | ||
# another leading expr comment | ||
foo # trailing expr comment | ||
# another trailing expr comment | ||
): # dangling match comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
# leading match comment | ||
match ( # hello | ||
foo, # trailing expr comment # another | ||
): # dangling match comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
match [first, second, third]: # another comment # comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
match ( | ||
# comment | ||
"a b c" | ||
).split(): # another comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
match ( | ||
# comment | ||
# let's go | ||
yield foo | ||
): # another comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
match aaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh: # comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
def foo(): | ||
match inside_func: # comment | ||
case NOT_YET_IMPLEMENTED_MatchCase: | ||
pass | ||
``` | ||
|
||
|
||
|