mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-28 22:35:02 +00:00
Commit snapshot
This commit is contained in:
parent
9eb0752cb4
commit
027db8f242
1 changed files with 560 additions and 0 deletions
560
parser/src/snapshots/rustpython_parser__parser__tests__parse_function_definition.snap
generated
Normal file
560
parser/src/snapshots/rustpython_parser__parser__tests__parse_function_definition.snap
generated
Normal file
|
@ -0,0 +1,560 @@
|
||||||
|
---
|
||||||
|
source: parser/src/parser.rs
|
||||||
|
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||||
|
---
|
||||||
|
[
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 0..20,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 9..10,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ArgWithDefault {
|
||||||
|
range: 9..10,
|
||||||
|
def: Arg {
|
||||||
|
range: 9..10,
|
||||||
|
arg: Identifier(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
annotation: None,
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 17..20,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 17..20,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: None,
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 22..53,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 34..38,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ArgWithDefault {
|
||||||
|
range: 34..38,
|
||||||
|
def: Arg {
|
||||||
|
range: 34..38,
|
||||||
|
arg: Identifier(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 37..38,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 50..53,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 50..53,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 43..44,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 31..32,
|
||||||
|
name: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
bound: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 55..91,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 72..76,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ArgWithDefault {
|
||||||
|
range: 72..76,
|
||||||
|
def: Arg {
|
||||||
|
range: 72..76,
|
||||||
|
arg: Identifier(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 75..76,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 88..91,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 88..91,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 81..82,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 64..70,
|
||||||
|
name: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
bound: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 67..70,
|
||||||
|
id: Identifier(
|
||||||
|
"str",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 93..138,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 119..123,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ArgWithDefault {
|
||||||
|
range: 119..123,
|
||||||
|
def: Arg {
|
||||||
|
range: 119..123,
|
||||||
|
arg: Identifier(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 122..123,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 135..138,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 135..138,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 128..129,
|
||||||
|
id: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 102..117,
|
||||||
|
name: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
bound: Some(
|
||||||
|
Tuple(
|
||||||
|
ExprTuple {
|
||||||
|
range: 105..117,
|
||||||
|
elts: [
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 106..109,
|
||||||
|
id: Identifier(
|
||||||
|
"str",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 111..116,
|
||||||
|
id: Identifier(
|
||||||
|
"bytes",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 140..171,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 154..161,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: Some(
|
||||||
|
Arg {
|
||||||
|
range: 155..161,
|
||||||
|
arg: Identifier(
|
||||||
|
"a",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Starred(
|
||||||
|
ExprStarred {
|
||||||
|
range: 158..161,
|
||||||
|
value: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 159..161,
|
||||||
|
id: Identifier(
|
||||||
|
"Ts",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 168..171,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 168..171,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: None,
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
TypeVarTuple(
|
||||||
|
TypeParamTypeVarTuple {
|
||||||
|
range: 149..152,
|
||||||
|
name: Identifier(
|
||||||
|
"Ts",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 173..230,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 187..220,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: Some(
|
||||||
|
Arg {
|
||||||
|
range: 188..200,
|
||||||
|
arg: Identifier(
|
||||||
|
"args",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Attribute(
|
||||||
|
ExprAttribute {
|
||||||
|
range: 194..200,
|
||||||
|
value: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 194..195,
|
||||||
|
id: Identifier(
|
||||||
|
"P",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
attr: Identifier(
|
||||||
|
"args",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: Some(
|
||||||
|
Arg {
|
||||||
|
range: 204..220,
|
||||||
|
arg: Identifier(
|
||||||
|
"kwargs",
|
||||||
|
),
|
||||||
|
annotation: Some(
|
||||||
|
Attribute(
|
||||||
|
ExprAttribute {
|
||||||
|
range: 212..220,
|
||||||
|
value: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 212..213,
|
||||||
|
id: Identifier(
|
||||||
|
"P",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
attr: Identifier(
|
||||||
|
"kwargs",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
type_comment: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 227..230,
|
||||||
|
value: Constant(
|
||||||
|
ExprConstant {
|
||||||
|
range: 227..230,
|
||||||
|
value: Ellipsis,
|
||||||
|
kind: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: None,
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
ParamSpec(
|
||||||
|
TypeParamParamSpec {
|
||||||
|
range: 182..185,
|
||||||
|
name: Identifier(
|
||||||
|
"P",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 232..273,
|
||||||
|
name: Identifier(
|
||||||
|
"func",
|
||||||
|
),
|
||||||
|
args: Arguments {
|
||||||
|
range: 261..263,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
body: [
|
||||||
|
Pass(
|
||||||
|
StmtPass {
|
||||||
|
range: 269..273,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
decorator_list: [],
|
||||||
|
returns: None,
|
||||||
|
type_comment: None,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 241..242,
|
||||||
|
name: Identifier(
|
||||||
|
"T",
|
||||||
|
),
|
||||||
|
bound: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 244..250,
|
||||||
|
name: Identifier(
|
||||||
|
"U",
|
||||||
|
),
|
||||||
|
bound: Some(
|
||||||
|
Name(
|
||||||
|
ExprName {
|
||||||
|
range: 247..250,
|
||||||
|
id: Identifier(
|
||||||
|
"str",
|
||||||
|
),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TypeVarTuple(
|
||||||
|
TypeParamTypeVarTuple {
|
||||||
|
range: 252..255,
|
||||||
|
name: Identifier(
|
||||||
|
"Ts",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ParamSpec(
|
||||||
|
TypeParamParamSpec {
|
||||||
|
range: 257..260,
|
||||||
|
name: Identifier(
|
||||||
|
"P",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue