-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider exactly
_
for wildcard pattern (#10896)
- Loading branch information
1 parent
8ef7d36
commit b156d0b
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
crates/ruff_python_parser/resources/inline/ok/match_as_pattern.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,3 @@ | ||
match foo: | ||
case foo_bar: ... | ||
case _: ... |
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
80 changes: 80 additions & 0 deletions
80
crates/ruff_python_parser/tests/snapshots/valid_syntax@match_as_pattern.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,80 @@ | ||
--- | ||
source: crates/ruff_python_parser/tests/fixtures.rs | ||
input_file: crates/ruff_python_parser/resources/inline/ok/match_as_pattern.py | ||
--- | ||
## AST | ||
|
||
``` | ||
Module( | ||
ModModule { | ||
range: 0..49, | ||
body: [ | ||
Match( | ||
StmtMatch { | ||
range: 0..48, | ||
subject: Name( | ||
ExprName { | ||
range: 6..9, | ||
id: "foo", | ||
ctx: Load, | ||
}, | ||
), | ||
cases: [ | ||
MatchCase { | ||
range: 15..32, | ||
pattern: MatchAs( | ||
PatternMatchAs { | ||
range: 20..27, | ||
pattern: None, | ||
name: Some( | ||
Identifier { | ||
id: "foo_bar", | ||
range: 20..27, | ||
}, | ||
), | ||
}, | ||
), | ||
guard: None, | ||
body: [ | ||
Expr( | ||
StmtExpr { | ||
range: 29..32, | ||
value: EllipsisLiteral( | ||
ExprEllipsisLiteral { | ||
range: 29..32, | ||
}, | ||
), | ||
}, | ||
), | ||
], | ||
}, | ||
MatchCase { | ||
range: 37..48, | ||
pattern: MatchAs( | ||
PatternMatchAs { | ||
range: 42..43, | ||
pattern: None, | ||
name: None, | ||
}, | ||
), | ||
guard: None, | ||
body: [ | ||
Expr( | ||
StmtExpr { | ||
range: 45..48, | ||
value: EllipsisLiteral( | ||
ExprEllipsisLiteral { | ||
range: 45..48, | ||
}, | ||
), | ||
}, | ||
), | ||
], | ||
}, | ||
], | ||
}, | ||
), | ||
], | ||
}, | ||
) | ||
``` |