mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Format PatternMatchAs
(#6652)
## Summary Add formatting for `PatternMatchAs`. This closes #6641. ## Test Plan Add tests for comments.
This commit is contained in:
parent
42ff833d00
commit
c34a342ab4
11 changed files with 159 additions and 79 deletions
|
@ -143,6 +143,35 @@ match pattern_comments:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
# 1
|
||||||
|
pattern # 2
|
||||||
|
# 3
|
||||||
|
as # 4
|
||||||
|
# 5
|
||||||
|
name # 6
|
||||||
|
# 7
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
pattern
|
||||||
|
# 1
|
||||||
|
as # 2
|
||||||
|
# 3
|
||||||
|
name #4
|
||||||
|
# 5
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match x:
|
||||||
|
case (a as b) as c:
|
||||||
|
pass
|
||||||
|
|
||||||
match pattern_singleton:
|
match pattern_singleton:
|
||||||
case (
|
case (
|
||||||
# leading 1
|
# leading 1
|
||||||
|
|
|
@ -1,19 +1,42 @@
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::{write, Buffer, FormatResult};
|
||||||
use ruff_python_ast::PatternMatchAs;
|
use ruff_python_ast::{Pattern, PatternMatchAs};
|
||||||
|
|
||||||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
use crate::expression::parentheses::parenthesized;
|
||||||
|
use crate::prelude::*;
|
||||||
|
use crate::{FormatNodeRule, PyFormatter};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct FormatPatternMatchAs;
|
pub struct FormatPatternMatchAs;
|
||||||
|
|
||||||
impl FormatNodeRule<PatternMatchAs> for FormatPatternMatchAs {
|
impl FormatNodeRule<PatternMatchAs> for FormatPatternMatchAs {
|
||||||
fn fmt_fields(&self, item: &PatternMatchAs, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, item: &PatternMatchAs, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(
|
let PatternMatchAs {
|
||||||
f,
|
range: _,
|
||||||
[not_yet_implemented_custom_text(
|
pattern,
|
||||||
"x as NOT_YET_IMPLEMENTED_PatternMatchAs",
|
name,
|
||||||
item
|
} = item;
|
||||||
)]
|
|
||||||
)
|
if let Some(name) = name {
|
||||||
|
if let Some(pattern) = pattern {
|
||||||
|
// Parenthesize nested `PatternMatchAs` like `(a as b) as c`.
|
||||||
|
if matches!(
|
||||||
|
pattern.as_ref(),
|
||||||
|
Pattern::MatchAs(PatternMatchAs {
|
||||||
|
pattern: Some(_),
|
||||||
|
..
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
parenthesized("(", &pattern.format(), ")").fmt(f)?;
|
||||||
|
} else {
|
||||||
|
pattern.format().fmt(f)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(f, [space(), text("as"), space()])?;
|
||||||
|
}
|
||||||
|
name.format().fmt(f)
|
||||||
|
} else {
|
||||||
|
debug_assert!(pattern.is_none());
|
||||||
|
text("_").fmt(f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ match x:
|
||||||
y = 0
|
y = 0
|
||||||
# case black_test_patma_233
|
# case black_test_patma_233
|
||||||
match x:
|
match x:
|
||||||
@@ -116,29 +116,29 @@
|
@@ -116,11 +116,11 @@
|
||||||
y = 0
|
y = 0
|
||||||
# case black_test_patma_078
|
# case black_test_patma_078
|
||||||
match x:
|
match x:
|
||||||
|
@ -316,8 +316,7 @@ match x:
|
||||||
y = 2
|
y = 2
|
||||||
# case black_test_patma_156
|
# case black_test_patma_156
|
||||||
match x:
|
match x:
|
||||||
- case z:
|
@@ -128,17 +128,17 @@
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
y = 0
|
y = 0
|
||||||
# case black_test_patma_189
|
# case black_test_patma_189
|
||||||
match w:
|
match w:
|
||||||
|
@ -471,7 +470,7 @@ match x:
|
||||||
y = 2
|
y = 2
|
||||||
# case black_test_patma_156
|
# case black_test_patma_156
|
||||||
match x:
|
match x:
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case z:
|
||||||
y = 0
|
y = 0
|
||||||
# case black_test_patma_189
|
# case black_test_patma_189
|
||||||
match w:
|
match w:
|
||||||
|
|
|
@ -149,25 +149,23 @@ match bar1:
|
||||||
print(x, y)
|
print(x, y)
|
||||||
|
|
||||||
|
|
||||||
@@ -15,40 +15,43 @@
|
@@ -15,7 +15,7 @@
|
||||||
case: int = re.match(something)
|
case: int = re.match(something)
|
||||||
|
|
||||||
match re.match(case):
|
match re.match(case):
|
||||||
- case type("match", match):
|
- case type("match", match):
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
pass
|
pass
|
||||||
- case match:
|
case match:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
pass
|
pass
|
||||||
|
@@ -23,32 +23,35 @@
|
||||||
|
|
||||||
def func(match: case, case: match) -> case:
|
def func(match: case, case: match) -> case:
|
||||||
match Something():
|
match Something():
|
||||||
- case func(match, case):
|
- case func(match, case):
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
...
|
...
|
||||||
- case another:
|
case another:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,8 +189,7 @@ match bar1:
|
||||||
- case [[5], (6)], [7],:
|
- case [[5], (6)], [7],:
|
||||||
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
pass
|
pass
|
||||||
- case _:
|
case _:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +202,7 @@ match bar1:
|
||||||
assert "map" == b
|
assert "map" == b
|
||||||
|
|
||||||
|
|
||||||
@@ -59,61 +62,51 @@
|
@@ -59,15 +62,10 @@
|
||||||
),
|
),
|
||||||
case,
|
case,
|
||||||
):
|
):
|
||||||
|
@ -222,15 +219,8 @@ match bar1:
|
||||||
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
- case case:
|
case case:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
@@ -80,40 +78,35 @@
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
match match:
|
|
||||||
- case case:
|
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
match a, *b(), c:
|
match a, *b(), c:
|
||||||
|
@ -253,7 +243,7 @@ match bar1:
|
||||||
|
|
||||||
match something:
|
match something:
|
||||||
- case 1 as a:
|
- case 1 as a:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
+ case "NOT_YET_IMPLEMENTED_PatternMatchValue" as a:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
- case 2 as b, 3 as c:
|
- case 2 as b, 3 as c:
|
||||||
|
@ -269,8 +259,7 @@ match bar1:
|
||||||
- case Foo(aa=Callable() as aa, bb=int()):
|
- case Foo(aa=Callable() as aa, bb=int()):
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print(bar1.aa, bar1.bb)
|
print(bar1.aa, bar1.bb)
|
||||||
- case _:
|
case _:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
print("no match", "\n")
|
print("no match", "\n")
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +293,7 @@ case: int = re.match(something)
|
||||||
match re.match(case):
|
match re.match(case):
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
pass
|
pass
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case match:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,7 +301,7 @@ def func(match: case, case: match) -> case:
|
||||||
match Something():
|
match Something():
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
...
|
...
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case another:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -331,7 +320,7 @@ match (
|
||||||
pass
|
pass
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
pass
|
pass
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,12 +344,12 @@ match match(
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case case:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
match match:
|
match match:
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case case:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +366,7 @@ match something:
|
||||||
|
|
||||||
|
|
||||||
match something:
|
match something:
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case "NOT_YET_IMPLEMENTED_PatternMatchValue" as a:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
|
@ -390,7 +379,7 @@ match something:
|
||||||
match bar1:
|
match bar1:
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print(bar1.aa, bar1.bb)
|
print(bar1.aa, bar1.bb)
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
print("no match", "\n")
|
print("no match", "\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,18 +119,6 @@ with match() as match:
|
||||||
```diff
|
```diff
|
||||||
--- Black
|
--- Black
|
||||||
+++ Ruff
|
+++ Ruff
|
||||||
@@ -24,9 +24,9 @@
|
|
||||||
]
|
|
||||||
|
|
||||||
match match:
|
|
||||||
- case case:
|
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
match match:
|
|
||||||
- case case:
|
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if all(version.is_python2() for version in target_versions):
|
|
||||||
@@ -46,7 +46,7 @@
|
@@ -46,7 +46,7 @@
|
||||||
def test_patma_139(self):
|
def test_patma_139(self):
|
||||||
x = False
|
x = False
|
||||||
|
@ -188,9 +176,9 @@ def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
|
||||||
]
|
]
|
||||||
|
|
||||||
match match:
|
match match:
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case case:
|
||||||
match match:
|
match match:
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case case:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if all(version.is_python2() for version in target_versions):
|
if all(version.is_python2() for version in target_versions):
|
||||||
|
|
|
@ -153,8 +153,7 @@ def where_is(point):
|
||||||
- case ["drop", *objects]:
|
- case ["drop", *objects]:
|
||||||
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
+ case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
print("Dropping: ", *objects)
|
print("Dropping: ", *objects)
|
||||||
- case _:
|
case _:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
print(f"Sorry, I couldn't understand {command!r}")
|
print(f"Sorry, I couldn't understand {command!r}")
|
||||||
|
|
||||||
match command.split():
|
match command.split():
|
||||||
|
@ -197,8 +196,7 @@ def where_is(point):
|
||||||
- case KeyPress():
|
- case KeyPress():
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
pass # Ignore other keystrokes
|
pass # Ignore other keystrokes
|
||||||
- case other_event:
|
case other_event:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
raise ValueError(f"Unrecognized event: {other_event}")
|
raise ValueError(f"Unrecognized event: {other_event}")
|
||||||
|
|
||||||
match event.get():
|
match event.get():
|
||||||
|
@ -224,8 +222,7 @@ def where_is(point):
|
||||||
- case Point():
|
- case Point():
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print("Somewhere else")
|
print("Somewhere else")
|
||||||
- case _:
|
case _:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
print("Not a point")
|
print("Not a point")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -269,7 +266,7 @@ match command.split():
|
||||||
print("Going:", direction)
|
print("Going:", direction)
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
print("Dropping: ", *objects)
|
print("Dropping: ", *objects)
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
print(f"Sorry, I couldn't understand {command!r}")
|
print(f"Sorry, I couldn't understand {command!r}")
|
||||||
|
|
||||||
match command.split():
|
match command.split():
|
||||||
|
@ -302,7 +299,7 @@ match event.get():
|
||||||
game.go_north()
|
game.go_north()
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
pass # Ignore other keystrokes
|
pass # Ignore other keystrokes
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case other_event:
|
||||||
raise ValueError(f"Unrecognized event: {other_event}")
|
raise ValueError(f"Unrecognized event: {other_event}")
|
||||||
|
|
||||||
match event.get():
|
match event.get():
|
||||||
|
@ -322,7 +319,7 @@ def where_is(point):
|
||||||
print(f"X={x}")
|
print(f"X={x}")
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print("Somewhere else")
|
print("Somewhere else")
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
print("Not a point")
|
print("Not a point")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,7 @@ match match(
|
||||||
- ):
|
- ):
|
||||||
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
+ case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print(2)
|
print(2)
|
||||||
- case a:
|
case a:
|
||||||
+ case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
-match(arg) # comment
|
-match(arg) # comment
|
||||||
|
@ -127,7 +126,7 @@ match something:
|
||||||
print(1)
|
print(1)
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print(2)
|
print(2)
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case a:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
match(
|
match(
|
||||||
|
|
|
@ -89,7 +89,7 @@ def http_error(status):
|
||||||
return "Not found"
|
return "Not found"
|
||||||
case "NOT_YET_IMPLEMENTED_PatternMatchValue":
|
case "NOT_YET_IMPLEMENTED_PatternMatchValue":
|
||||||
return "I'm a teapot"
|
return "I'm a teapot"
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
return "Something's wrong with the internet"
|
return "Something's wrong with the internet"
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ match point:
|
||||||
print(f"X={x}")
|
print(f"X={x}")
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
print(f"X={x}, Y={y}")
|
print(f"X={x}, Y={y}")
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
raise ValueError("Not a point")
|
raise ValueError("Not a point")
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ def location(point):
|
||||||
print(f"X={x} and the point is on the x-axis.")
|
print(f"X={x} and the point is on the x-axis.")
|
||||||
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
case NOT_YET_IMPLEMENTED_PatternMatchClass(0, 0):
|
||||||
print("The point is located somewhere else on the plane.")
|
print("The point is located somewhere else on the plane.")
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
print("Not a point")
|
print("Not a point")
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ match points:
|
||||||
print(f"A single point {x}, {y} is in the list.")
|
print(f"A single point {x}, {y} is in the list.")
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
print(f"Two points on the Y axis at {y1}, {y2} are in the list.")
|
print(f"Two points on the Y axis at {y1}, {y2} are in the list.")
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
print("Something else is found in the list.")
|
print("Something else is found in the list.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ with ( # d 1
|
||||||
pass
|
pass
|
||||||
match ( # d 2
|
match ( # d 2
|
||||||
):
|
):
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case d2:
|
||||||
pass
|
pass
|
||||||
match d3:
|
match d3:
|
||||||
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
case [NOT_YET_IMPLEMENTED_PatternMatchSequence, 2]:
|
||||||
|
|
|
@ -219,12 +219,12 @@ with ( # d 1
|
||||||
match ( # d 2
|
match ( # d 2
|
||||||
x
|
x
|
||||||
):
|
):
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case d2:
|
||||||
pass
|
pass
|
||||||
match d3:
|
match d3:
|
||||||
case (
|
case (
|
||||||
# d 3
|
# d 3
|
||||||
x as NOT_YET_IMPLEMENTED_PatternMatchAs
|
x
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
while ( # d 4
|
while ( # d 4
|
||||||
|
|
|
@ -149,6 +149,35 @@ match pattern_comments:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
# 1
|
||||||
|
pattern # 2
|
||||||
|
# 3
|
||||||
|
as # 4
|
||||||
|
# 5
|
||||||
|
name # 6
|
||||||
|
# 7
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
pattern
|
||||||
|
# 1
|
||||||
|
as # 2
|
||||||
|
# 3
|
||||||
|
name #4
|
||||||
|
# 5
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match x:
|
||||||
|
case (a as b) as c:
|
||||||
|
pass
|
||||||
|
|
||||||
match pattern_singleton:
|
match pattern_singleton:
|
||||||
case (
|
case (
|
||||||
# leading 1
|
# leading 1
|
||||||
|
@ -247,7 +276,7 @@ match newlines:
|
||||||
|
|
||||||
case "NOT_YET_IMPLEMENTED_PatternMatchValue":
|
case "NOT_YET_IMPLEMENTED_PatternMatchValue":
|
||||||
pass
|
pass
|
||||||
case x as NOT_YET_IMPLEMENTED_PatternMatchAs:
|
case _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +303,7 @@ match long_lines:
|
||||||
|
|
||||||
match pattern_comments:
|
match pattern_comments:
|
||||||
case (
|
case (
|
||||||
x as NOT_YET_IMPLEMENTED_PatternMatchAs # trailing 1
|
only_trailing # trailing 1
|
||||||
# trailing 2
|
# trailing 2
|
||||||
# trailing 3
|
# trailing 3
|
||||||
):
|
):
|
||||||
|
@ -284,7 +313,7 @@ match pattern_comments:
|
||||||
match pattern_comments:
|
match pattern_comments:
|
||||||
case (
|
case (
|
||||||
# leading
|
# leading
|
||||||
x as NOT_YET_IMPLEMENTED_PatternMatchAs
|
only_leading
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -292,7 +321,7 @@ match pattern_comments:
|
||||||
match pattern_comments:
|
match pattern_comments:
|
||||||
case (
|
case (
|
||||||
# leading
|
# leading
|
||||||
x as NOT_YET_IMPLEMENTED_PatternMatchAs # trailing 1
|
leading_and_trailing # trailing 1
|
||||||
# trailing 2
|
# trailing 2
|
||||||
# trailing 3
|
# trailing 3
|
||||||
):
|
):
|
||||||
|
@ -300,10 +329,37 @@ match pattern_comments:
|
||||||
|
|
||||||
|
|
||||||
match pattern_comments:
|
match pattern_comments:
|
||||||
case (x as NOT_YET_IMPLEMENTED_PatternMatchAs):
|
case (no_comments):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
# 1
|
||||||
|
pattern as name # 2
|
||||||
|
# 3
|
||||||
|
# 4
|
||||||
|
# 5 # 6
|
||||||
|
# 7
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match pattern_comments:
|
||||||
|
case (
|
||||||
|
pattern as name
|
||||||
|
# 1
|
||||||
|
# 2
|
||||||
|
# 3 # 4
|
||||||
|
# 5
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
match x:
|
||||||
|
case (a as b) as c:
|
||||||
|
pass
|
||||||
|
|
||||||
match pattern_singleton:
|
match pattern_singleton:
|
||||||
case (
|
case (
|
||||||
# leading 1
|
# leading 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue