forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
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
117 changes: 117 additions & 0 deletions
117
..._parser/src/snapshots/ruff_python_parser__parser__tests__alias_stringized_annotation.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,117 @@ | ||
--- | ||
source: crates/ruff_python_parser/src/parser.rs | ||
expression: parse_ast | ||
--- | ||
[ | ||
ImportFrom( | ||
StmtImportFrom { | ||
range: 0..39, | ||
module: Some( | ||
Identifier { | ||
id: "typing_extensions", | ||
range: 5..22, | ||
}, | ||
), | ||
names: [ | ||
Alias { | ||
range: 30..39, | ||
name: Identifier { | ||
id: "TypeAlias", | ||
range: 30..39, | ||
}, | ||
asname: None, | ||
}, | ||
], | ||
level: Some( | ||
0, | ||
), | ||
}, | ||
), | ||
Assign( | ||
StmtAssign { | ||
range: 42..83, | ||
targets: [ | ||
Name( | ||
ExprName { | ||
range: 42..48, | ||
id: "Alias1", | ||
ctx: Store, | ||
}, | ||
), | ||
], | ||
value: BinOp( | ||
ExprBinOp { | ||
range: 57..81, | ||
left: BinOp( | ||
ExprBinOp { | ||
range: 57..70, | ||
left: Name( | ||
ExprName { | ||
range: 57..60, | ||
id: "int", | ||
ctx: Load, | ||
}, | ||
), | ||
op: BitOr, | ||
right: Name( | ||
ExprName { | ||
range: 67..70, | ||
id: "str", | ||
ctx: Load, | ||
}, | ||
), | ||
}, | ||
), | ||
op: BitOr, | ||
right: Name( | ||
ExprName { | ||
range: 77..81, | ||
id: "bool", | ||
ctx: Load, | ||
}, | ||
), | ||
}, | ||
), | ||
}, | ||
), | ||
AnnAssign( | ||
StmtAnnAssign { | ||
range: 109..165, | ||
target: Name( | ||
ExprName { | ||
range: 109..115, | ||
id: "Alias2", | ||
ctx: Store, | ||
}, | ||
), | ||
annotation: Name( | ||
ExprName { | ||
range: 117..126, | ||
id: "TypeAlias", | ||
ctx: Load, | ||
}, | ||
), | ||
value: Some( | ||
StringLiteral( | ||
ExprStringLiteral { | ||
range: 129..165, | ||
value: StringLiteralValue { | ||
inner: Single( | ||
StringLiteral { | ||
range: 129..165, | ||
value: "\n int\n | str\n | bool\n", | ||
flags: StringLiteralFlags { | ||
quote_style: Double, | ||
prefix: Empty, | ||
triple_quoted: true, | ||
}, | ||
}, | ||
), | ||
}, | ||
}, | ||
), | ||
), | ||
simple: true, | ||
}, | ||
), | ||
] |
70 changes: 70 additions & 0 deletions
70
...python_parser/src/snapshots/ruff_python_parser__parser__tests__stringized_annotation.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,70 @@ | ||
--- | ||
source: crates/ruff_python_parser/src/parser.rs | ||
expression: parse_ast | ||
--- | ||
[ | ||
AnnAssign( | ||
StmtAnnAssign { | ||
range: 0..27, | ||
target: Name( | ||
ExprName { | ||
range: 0..1, | ||
id: "x", | ||
ctx: Store, | ||
}, | ||
), | ||
annotation: StringLiteral( | ||
ExprStringLiteral { | ||
range: 3..27, | ||
value: StringLiteralValue { | ||
inner: Single( | ||
StringLiteral { | ||
range: 3..27, | ||
value: "\n\n int |\n str\n", | ||
flags: StringLiteralFlags { | ||
quote_style: Double, | ||
prefix: Empty, | ||
triple_quoted: true, | ||
}, | ||
}, | ||
), | ||
}, | ||
}, | ||
), | ||
value: None, | ||
simple: true, | ||
}, | ||
), | ||
AnnAssign( | ||
StmtAnnAssign { | ||
range: 29..59, | ||
target: Name( | ||
ExprName { | ||
range: 29..30, | ||
id: "y", | ||
ctx: Store, | ||
}, | ||
), | ||
annotation: StringLiteral( | ||
ExprStringLiteral { | ||
range: 32..59, | ||
value: StringLiteralValue { | ||
inner: Single( | ||
StringLiteral { | ||
range: 32..59, | ||
value: "(\n int |\n str\n)", | ||
flags: StringLiteralFlags { | ||
quote_style: Double, | ||
prefix: Empty, | ||
triple_quoted: true, | ||
}, | ||
}, | ||
), | ||
}, | ||
}, | ||
), | ||
value: None, | ||
simple: true, | ||
}, | ||
), | ||
] |