mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
[syntax-errors] Extend annotation checks to await
(#17282)
Summary -- This PR extends the changes in #17101 to include `await` in the same positions. I also renamed the `valid_annotation_function` test to include `_py313` and explicitly passed a Python version to contrast it with the `_py314` version. Test Plan -- New test cases added to existing files.
This commit is contained in:
parent
b662c3ff7e
commit
127a45622f
13 changed files with 1399 additions and 314 deletions
|
@ -3,3 +3,5 @@ class I[T]((yield 1)): ...
|
||||||
class J[T]((yield from 1)): ...
|
class J[T]((yield from 1)): ...
|
||||||
class K[T: (yield 1)]: ... # yield in TypeVar
|
class K[T: (yield 1)]: ... # yield in TypeVar
|
||||||
class L[T: (x := 1)]: ... # named expr in TypeVar
|
class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
|
class M[T]((await 1)): ...
|
||||||
|
class N[T: (await 1)]: ...
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
def d[T]() -> (await 1): ...
|
||||||
|
def e[T](arg: (await 1)): ...
|
||||||
def f[T]() -> (y := 3): ...
|
def f[T]() -> (y := 3): ...
|
||||||
def g[T](arg: (x := 1)): ...
|
def g[T](arg: (x := 1)): ...
|
||||||
def h[T](x: (yield 1)): ...
|
def h[T](x: (yield 1)): ...
|
||||||
|
@ -12,3 +14,7 @@ def t[T: (x := 1)](): ... # named expr in TypeVar bound
|
||||||
def u[T = (x := 1)](): ... # named expr in TypeVar default
|
def u[T = (x := 1)](): ... # named expr in TypeVar default
|
||||||
def v[*Ts = (x := 1)](): ... # named expr in TypeVarTuple default
|
def v[*Ts = (x := 1)](): ... # named expr in TypeVarTuple default
|
||||||
def w[**Ts = (x := 1)](): ... # named expr in ParamSpec default
|
def w[**Ts = (x := 1)](): ... # named expr in ParamSpec default
|
||||||
|
def t[T: (await 1)](): ... # await in TypeVar bound
|
||||||
|
def u[T = (await 1)](): ... # await in TypeVar default
|
||||||
|
def v[*Ts = (await 1)](): ... # await in TypeVarTuple default
|
||||||
|
def w[**Ts = (await 1)](): ... # await in ParamSpec default
|
||||||
|
|
|
@ -6,3 +6,6 @@ def outer():
|
||||||
def k() -> (yield 1): ...
|
def k() -> (yield 1): ...
|
||||||
def m(x: (yield from 1)): ...
|
def m(x: (yield from 1)): ...
|
||||||
def o() -> (yield from 1): ...
|
def o() -> (yield from 1): ...
|
||||||
|
async def outer():
|
||||||
|
def f() -> (await 1): ...
|
||||||
|
def g(arg: (await 1)): ...
|
||||||
|
|
|
@ -4,3 +4,5 @@ type X[*Ts = (yield 1)] = int # TypeVarTuple default
|
||||||
type X[**Ts = (yield 1)] = int # ParamSpec default
|
type X[**Ts = (yield 1)] = int # ParamSpec default
|
||||||
type Y = (yield 1) # yield in value
|
type Y = (yield 1) # yield in value
|
||||||
type Y = (x := 1) # named expr in value
|
type Y = (x := 1) # named expr in value
|
||||||
|
type Y[T: (await 1)] = int # await in bound
|
||||||
|
type Y = (await 1) # await in value
|
||||||
|
|
|
@ -2,3 +2,5 @@ class F(y := list): ...
|
||||||
def f():
|
def f():
|
||||||
class G((yield 1)): ...
|
class G((yield 1)): ...
|
||||||
class H((yield from 1)): ...
|
class H((yield from 1)): ...
|
||||||
|
async def f():
|
||||||
|
class G((await 1)): ...
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# parse_options: {"target-version": "3.13"}
|
||||||
def f() -> (y := 3): ...
|
def f() -> (y := 3): ...
|
||||||
def g(arg: (x := 1)): ...
|
def g(arg: (x := 1)): ...
|
||||||
def outer():
|
def outer():
|
||||||
|
@ -5,3 +6,6 @@ def outer():
|
||||||
def k() -> (yield 1): ...
|
def k() -> (yield 1): ...
|
||||||
def m(x: (yield from 1)): ...
|
def m(x: (yield from 1)): ...
|
||||||
def o() -> (yield from 1): ...
|
def o() -> (yield from 1): ...
|
||||||
|
async def outer():
|
||||||
|
def f() -> (await 1): ...
|
||||||
|
def g(arg: (await 1)): ...
|
|
@ -125,7 +125,8 @@ impl SemanticSyntaxChecker {
|
||||||
returns,
|
returns,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
// test_ok valid_annotation_function
|
// test_ok valid_annotation_function_py313
|
||||||
|
// # parse_options: {"target-version": "3.13"}
|
||||||
// def f() -> (y := 3): ...
|
// def f() -> (y := 3): ...
|
||||||
// def g(arg: (x := 1)): ...
|
// def g(arg: (x := 1)): ...
|
||||||
// def outer():
|
// def outer():
|
||||||
|
@ -133,6 +134,9 @@ impl SemanticSyntaxChecker {
|
||||||
// def k() -> (yield 1): ...
|
// def k() -> (yield 1): ...
|
||||||
// def m(x: (yield from 1)): ...
|
// def m(x: (yield from 1)): ...
|
||||||
// def o() -> (yield from 1): ...
|
// def o() -> (yield from 1): ...
|
||||||
|
// async def outer():
|
||||||
|
// def f() -> (await 1): ...
|
||||||
|
// def g(arg: (await 1)): ...
|
||||||
|
|
||||||
// test_err invalid_annotation_function_py314
|
// test_err invalid_annotation_function_py314
|
||||||
// # parse_options: {"target-version": "3.14"}
|
// # parse_options: {"target-version": "3.14"}
|
||||||
|
@ -143,8 +147,13 @@ impl SemanticSyntaxChecker {
|
||||||
// def k() -> (yield 1): ...
|
// def k() -> (yield 1): ...
|
||||||
// def m(x: (yield from 1)): ...
|
// def m(x: (yield from 1)): ...
|
||||||
// def o() -> (yield from 1): ...
|
// def o() -> (yield from 1): ...
|
||||||
|
// async def outer():
|
||||||
|
// def f() -> (await 1): ...
|
||||||
|
// def g(arg: (await 1)): ...
|
||||||
|
|
||||||
// test_err invalid_annotation_function
|
// test_err invalid_annotation_function
|
||||||
|
// def d[T]() -> (await 1): ...
|
||||||
|
// def e[T](arg: (await 1)): ...
|
||||||
// def f[T]() -> (y := 3): ...
|
// def f[T]() -> (y := 3): ...
|
||||||
// def g[T](arg: (x := 1)): ...
|
// def g[T](arg: (x := 1)): ...
|
||||||
// def h[T](x: (yield 1)): ...
|
// def h[T](x: (yield 1)): ...
|
||||||
|
@ -159,6 +168,10 @@ impl SemanticSyntaxChecker {
|
||||||
// def u[T = (x := 1)](): ... # named expr in TypeVar default
|
// def u[T = (x := 1)](): ... # named expr in TypeVar default
|
||||||
// def v[*Ts = (x := 1)](): ... # named expr in TypeVarTuple default
|
// def v[*Ts = (x := 1)](): ... # named expr in TypeVarTuple default
|
||||||
// def w[**Ts = (x := 1)](): ... # named expr in ParamSpec default
|
// def w[**Ts = (x := 1)](): ... # named expr in ParamSpec default
|
||||||
|
// def t[T: (await 1)](): ... # await in TypeVar bound
|
||||||
|
// def u[T = (await 1)](): ... # await in TypeVar default
|
||||||
|
// def v[*Ts = (await 1)](): ... # await in TypeVarTuple default
|
||||||
|
// def w[**Ts = (await 1)](): ... # await in ParamSpec default
|
||||||
let mut visitor = InvalidExpressionVisitor {
|
let mut visitor = InvalidExpressionVisitor {
|
||||||
position: InvalidExpressionPosition::TypeAnnotation,
|
position: InvalidExpressionPosition::TypeAnnotation,
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -194,6 +207,8 @@ impl SemanticSyntaxChecker {
|
||||||
// def f():
|
// def f():
|
||||||
// class G((yield 1)): ...
|
// class G((yield 1)): ...
|
||||||
// class H((yield from 1)): ...
|
// class H((yield from 1)): ...
|
||||||
|
// async def f():
|
||||||
|
// class G((await 1)): ...
|
||||||
|
|
||||||
// test_err invalid_annotation_class
|
// test_err invalid_annotation_class
|
||||||
// class F[T](y := list): ...
|
// class F[T](y := list): ...
|
||||||
|
@ -201,6 +216,8 @@ impl SemanticSyntaxChecker {
|
||||||
// class J[T]((yield from 1)): ...
|
// class J[T]((yield from 1)): ...
|
||||||
// class K[T: (yield 1)]: ... # yield in TypeVar
|
// class K[T: (yield 1)]: ... # yield in TypeVar
|
||||||
// class L[T: (x := 1)]: ... # named expr in TypeVar
|
// class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
|
// class M[T]((await 1)): ...
|
||||||
|
// class N[T: (await 1)]: ...
|
||||||
let mut visitor = InvalidExpressionVisitor {
|
let mut visitor = InvalidExpressionVisitor {
|
||||||
position: InvalidExpressionPosition::TypeAnnotation,
|
position: InvalidExpressionPosition::TypeAnnotation,
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -221,6 +238,8 @@ impl SemanticSyntaxChecker {
|
||||||
// type X[**Ts = (yield 1)] = int # ParamSpec default
|
// type X[**Ts = (yield 1)] = int # ParamSpec default
|
||||||
// type Y = (yield 1) # yield in value
|
// type Y = (yield 1) # yield in value
|
||||||
// type Y = (x := 1) # named expr in value
|
// type Y = (x := 1) # named expr in value
|
||||||
|
// type Y[T: (await 1)] = int # await in bound
|
||||||
|
// type Y = (await 1) # await in value
|
||||||
let mut visitor = InvalidExpressionVisitor {
|
let mut visitor = InvalidExpressionVisitor {
|
||||||
position: InvalidExpressionPosition::TypeAlias,
|
position: InvalidExpressionPosition::TypeAlias,
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -878,6 +897,7 @@ impl Display for InvalidExpressionPosition {
|
||||||
pub enum InvalidExpressionKind {
|
pub enum InvalidExpressionKind {
|
||||||
Yield,
|
Yield,
|
||||||
NamedExpr,
|
NamedExpr,
|
||||||
|
Await,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for InvalidExpressionKind {
|
impl Display for InvalidExpressionKind {
|
||||||
|
@ -885,6 +905,7 @@ impl Display for InvalidExpressionKind {
|
||||||
f.write_str(match self {
|
f.write_str(match self {
|
||||||
InvalidExpressionKind::Yield => "yield expression",
|
InvalidExpressionKind::Yield => "yield expression",
|
||||||
InvalidExpressionKind::NamedExpr => "named expression",
|
InvalidExpressionKind::NamedExpr => "named expression",
|
||||||
|
InvalidExpressionKind::Await => "await expression",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1115,6 +1136,16 @@ where
|
||||||
*range,
|
*range,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Expr::Await(ast::ExprAwait { range, .. }) => {
|
||||||
|
SemanticSyntaxChecker::add_error(
|
||||||
|
self.ctx,
|
||||||
|
SemanticSyntaxErrorKind::InvalidExpression(
|
||||||
|
InvalidExpressionKind::Await,
|
||||||
|
self.position,
|
||||||
|
),
|
||||||
|
*range,
|
||||||
|
);
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
ast::visitor::walk_expr(self, expr);
|
ast::visitor::walk_expr(self, expr);
|
||||||
|
|
|
@ -7,7 +7,7 @@ input_file: crates/ruff_python_parser/resources/inline/err/invalid_annotation_cl
|
||||||
```
|
```
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
range: 0..193,
|
range: 0..247,
|
||||||
body: [
|
body: [
|
||||||
ClassDef(
|
ClassDef(
|
||||||
StmtClassDef {
|
StmtClassDef {
|
||||||
|
@ -319,6 +319,122 @@ Module(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ClassDef(
|
||||||
|
StmtClassDef {
|
||||||
|
range: 193..219,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("M"),
|
||||||
|
range: 199..200,
|
||||||
|
},
|
||||||
|
type_params: Some(
|
||||||
|
TypeParams {
|
||||||
|
range: 200..203,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 201..202,
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("T"),
|
||||||
|
range: 201..202,
|
||||||
|
},
|
||||||
|
bound: None,
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
arguments: Some(
|
||||||
|
Arguments {
|
||||||
|
range: 203..214,
|
||||||
|
args: [
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 205..212,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 211..212,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
keywords: [],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 216..219,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 216..219,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ClassDef(
|
||||||
|
StmtClassDef {
|
||||||
|
range: 220..246,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("N"),
|
||||||
|
range: 226..227,
|
||||||
|
},
|
||||||
|
type_params: Some(
|
||||||
|
TypeParams {
|
||||||
|
range: 227..241,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 228..240,
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("T"),
|
||||||
|
range: 228..229,
|
||||||
|
},
|
||||||
|
bound: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 232..239,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 238..239,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
arguments: None,
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 243..246,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 243..246,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -358,6 +474,7 @@ Module(
|
||||||
4 | class K[T: (yield 1)]: ... # yield in TypeVar
|
4 | class K[T: (yield 1)]: ... # yield in TypeVar
|
||||||
| ^^^^^^^ Syntax Error: yield expression cannot be used within a TypeVar bound
|
| ^^^^^^^ Syntax Error: yield expression cannot be used within a TypeVar bound
|
||||||
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
|
6 | class M[T]((await 1)): ...
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,4 +483,23 @@ Module(
|
||||||
4 | class K[T: (yield 1)]: ... # yield in TypeVar
|
4 | class K[T: (yield 1)]: ... # yield in TypeVar
|
||||||
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
| ^^^^^^ Syntax Error: named expression cannot be used within a TypeVar bound
|
| ^^^^^^ Syntax Error: named expression cannot be used within a TypeVar bound
|
||||||
|
6 | class M[T]((await 1)): ...
|
||||||
|
7 | class N[T: (await 1)]: ...
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
4 | class K[T: (yield 1)]: ... # yield in TypeVar
|
||||||
|
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
|
6 | class M[T]((await 1)): ...
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a generic definition
|
||||||
|
7 | class N[T: (await 1)]: ...
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
5 | class L[T: (x := 1)]: ... # named expr in TypeVar
|
||||||
|
6 | class M[T]((await 1)): ...
|
||||||
|
7 | class N[T: (await 1)]: ...
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a TypeVar bound
|
||||||
|
|
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ input_file: crates/ruff_python_parser/resources/inline/err/invalid_annotation_fu
|
||||||
```
|
```
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
range: 0..236,
|
range: 0..316,
|
||||||
body: [
|
body: [
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
|
@ -371,6 +371,136 @@ Module(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 236..315,
|
||||||
|
is_async: true,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("outer"),
|
||||||
|
range: 246..251,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 251..253,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: None,
|
||||||
|
body: [
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 259..284,
|
||||||
|
is_async: false,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("f"),
|
||||||
|
range: 263..264,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 264..266,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 271..278,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 277..278,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 281..284,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 281..284,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 289..315,
|
||||||
|
is_async: false,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("g"),
|
||||||
|
range: 293..294,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 294..310,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ParameterWithDefault {
|
||||||
|
range: 295..309,
|
||||||
|
parameter: Parameter {
|
||||||
|
range: 295..309,
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("arg"),
|
||||||
|
range: 295..298,
|
||||||
|
},
|
||||||
|
annotation: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 301..308,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 307..308,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: None,
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 312..315,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 312..315,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -422,12 +552,32 @@ Module(
|
||||||
7 | def m(x: (yield from 1)): ...
|
7 | def m(x: (yield from 1)): ...
|
||||||
| ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used within a type annotation
|
| ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used within a type annotation
|
||||||
8 | def o() -> (yield from 1): ...
|
8 | def o() -> (yield from 1): ...
|
||||||
|
9 | async def outer():
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
|
||||||
6 | def k() -> (yield 1): ...
|
6 | def k() -> (yield 1): ...
|
||||||
7 | def m(x: (yield from 1)): ...
|
7 | def m(x: (yield from 1)): ...
|
||||||
8 | def o() -> (yield from 1): ...
|
8 | def o() -> (yield from 1): ...
|
||||||
| ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used within a type annotation
|
| ^^^^^^^^^^^^ Syntax Error: yield expression cannot be used within a type annotation
|
||||||
|
|
9 | async def outer():
|
||||||
|
10 | def f() -> (await 1): ...
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
8 | def o() -> (yield from 1): ...
|
||||||
|
9 | async def outer():
|
||||||
|
10 | def f() -> (await 1): ...
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a type annotation
|
||||||
|
11 | def g(arg: (await 1)): ...
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
9 | async def outer():
|
||||||
|
10 | def f() -> (await 1): ...
|
||||||
|
11 | def g(arg: (await 1)): ...
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a type annotation
|
||||||
|
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ input_file: crates/ruff_python_parser/resources/inline/err/invalid_annotation_ty
|
||||||
```
|
```
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
range: 0..308,
|
range: 0..406,
|
||||||
body: [
|
body: [
|
||||||
TypeAlias(
|
TypeAlias(
|
||||||
StmtTypeAlias {
|
StmtTypeAlias {
|
||||||
|
@ -280,6 +280,83 @@ Module(
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
TypeAlias(
|
||||||
|
StmtTypeAlias {
|
||||||
|
range: 308..334,
|
||||||
|
name: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 313..314,
|
||||||
|
id: Name("Y"),
|
||||||
|
ctx: Store,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
type_params: Some(
|
||||||
|
TypeParams {
|
||||||
|
range: 314..328,
|
||||||
|
type_params: [
|
||||||
|
TypeVar(
|
||||||
|
TypeParamTypeVar {
|
||||||
|
range: 315..327,
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("T"),
|
||||||
|
range: 315..316,
|
||||||
|
},
|
||||||
|
bound: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 319..326,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 325..326,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
value: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 331..334,
|
||||||
|
id: Name("int"),
|
||||||
|
ctx: Load,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TypeAlias(
|
||||||
|
StmtTypeAlias {
|
||||||
|
range: 357..375,
|
||||||
|
name: Name(
|
||||||
|
ExprName {
|
||||||
|
range: 362..363,
|
||||||
|
id: Name("Y"),
|
||||||
|
ctx: Store,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
type_params: None,
|
||||||
|
value: Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 367..374,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 373..374,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -329,6 +406,7 @@ Module(
|
||||||
5 | type Y = (yield 1) # yield in value
|
5 | type Y = (yield 1) # yield in value
|
||||||
| ^^^^^^^ Syntax Error: yield expression cannot be used within a type alias
|
| ^^^^^^^ Syntax Error: yield expression cannot be used within a type alias
|
||||||
6 | type Y = (x := 1) # named expr in value
|
6 | type Y = (x := 1) # named expr in value
|
||||||
|
7 | type Y[T: (await 1)] = int # await in bound
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -337,4 +415,23 @@ Module(
|
||||||
5 | type Y = (yield 1) # yield in value
|
5 | type Y = (yield 1) # yield in value
|
||||||
6 | type Y = (x := 1) # named expr in value
|
6 | type Y = (x := 1) # named expr in value
|
||||||
| ^^^^^^ Syntax Error: named expression cannot be used within a type alias
|
| ^^^^^^ Syntax Error: named expression cannot be used within a type alias
|
||||||
|
7 | type Y[T: (await 1)] = int # await in bound
|
||||||
|
8 | type Y = (await 1) # await in value
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
5 | type Y = (yield 1) # yield in value
|
||||||
|
6 | type Y = (x := 1) # named expr in value
|
||||||
|
7 | type Y[T: (await 1)] = int # await in bound
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a TypeVar bound
|
||||||
|
8 | type Y = (await 1) # await in value
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
6 | type Y = (x := 1) # named expr in value
|
||||||
|
7 | type Y[T: (await 1)] = int # await in bound
|
||||||
|
8 | type Y = (await 1) # await in value
|
||||||
|
| ^^^^^^^ Syntax Error: await expression cannot be used within a type alias
|
||||||
|
|
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ input_file: crates/ruff_python_parser/resources/inline/ok/valid_annotation_class
|
||||||
```
|
```
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
range: 0..94,
|
range: 0..137,
|
||||||
body: [
|
body: [
|
||||||
ClassDef(
|
ClassDef(
|
||||||
StmtClassDef {
|
StmtClassDef {
|
||||||
|
@ -172,6 +172,73 @@ Module(
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 94..136,
|
||||||
|
is_async: true,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("f"),
|
||||||
|
range: 104..105,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 105..107,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: None,
|
||||||
|
body: [
|
||||||
|
ClassDef(
|
||||||
|
StmtClassDef {
|
||||||
|
range: 113..136,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("G"),
|
||||||
|
range: 119..120,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
arguments: Some(
|
||||||
|
Arguments {
|
||||||
|
range: 120..131,
|
||||||
|
args: [
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 122..129,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 128..129,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
keywords: [],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 133..136,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 133..136,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_python_parser/tests/fixtures.rs
|
source: crates/ruff_python_parser/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_parser/resources/inline/ok/valid_annotation_function.py
|
input_file: crates/ruff_python_parser/resources/inline/ok/valid_annotation_function_py313.py
|
||||||
---
|
---
|
||||||
## AST
|
## AST
|
||||||
|
|
||||||
```
|
```
|
||||||
Module(
|
Module(
|
||||||
ModModule {
|
ModModule {
|
||||||
range: 0..192,
|
range: 0..316,
|
||||||
body: [
|
body: [
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 0..24,
|
range: 44..68,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("f"),
|
id: Name("f"),
|
||||||
range: 4..5,
|
range: 48..49,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 5..7,
|
range: 49..51,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [],
|
args: [],
|
||||||
vararg: None,
|
vararg: None,
|
||||||
|
@ -30,17 +30,17 @@ Module(
|
||||||
returns: Some(
|
returns: Some(
|
||||||
Named(
|
Named(
|
||||||
ExprNamed {
|
ExprNamed {
|
||||||
range: 12..18,
|
range: 56..62,
|
||||||
target: Name(
|
target: Name(
|
||||||
ExprName {
|
ExprName {
|
||||||
range: 12..13,
|
range: 56..57,
|
||||||
id: Name("y"),
|
id: Name("y"),
|
||||||
ctx: Store,
|
ctx: Store,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
value: NumberLiteral(
|
value: NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 17..18,
|
range: 61..62,
|
||||||
value: Int(
|
value: Int(
|
||||||
3,
|
3,
|
||||||
),
|
),
|
||||||
|
@ -52,10 +52,10 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 21..24,
|
range: 65..68,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 21..24,
|
range: 65..68,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -65,40 +65,40 @@ Module(
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 25..50,
|
range: 69..94,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("g"),
|
id: Name("g"),
|
||||||
range: 29..30,
|
range: 73..74,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 30..45,
|
range: 74..89,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [
|
args: [
|
||||||
ParameterWithDefault {
|
ParameterWithDefault {
|
||||||
range: 31..44,
|
range: 75..88,
|
||||||
parameter: Parameter {
|
parameter: Parameter {
|
||||||
range: 31..44,
|
range: 75..88,
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("arg"),
|
id: Name("arg"),
|
||||||
range: 31..34,
|
range: 75..78,
|
||||||
},
|
},
|
||||||
annotation: Some(
|
annotation: Some(
|
||||||
Named(
|
Named(
|
||||||
ExprNamed {
|
ExprNamed {
|
||||||
range: 37..43,
|
range: 81..87,
|
||||||
target: Name(
|
target: Name(
|
||||||
ExprName {
|
ExprName {
|
||||||
range: 37..38,
|
range: 81..82,
|
||||||
id: Name("x"),
|
id: Name("x"),
|
||||||
ctx: Store,
|
ctx: Store,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
value: NumberLiteral(
|
value: NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 42..43,
|
range: 86..87,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
@ -119,10 +119,10 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 47..50,
|
range: 91..94,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 47..50,
|
range: 91..94,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -132,16 +132,16 @@ Module(
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 51..191,
|
range: 95..235,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("outer"),
|
id: Name("outer"),
|
||||||
range: 55..60,
|
range: 99..104,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 60..62,
|
range: 104..106,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [],
|
args: [],
|
||||||
vararg: None,
|
vararg: None,
|
||||||
|
@ -152,34 +152,34 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 68..92,
|
range: 112..136,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("i"),
|
id: Name("i"),
|
||||||
range: 72..73,
|
range: 116..117,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 73..87,
|
range: 117..131,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [
|
args: [
|
||||||
ParameterWithDefault {
|
ParameterWithDefault {
|
||||||
range: 74..86,
|
range: 118..130,
|
||||||
parameter: Parameter {
|
parameter: Parameter {
|
||||||
range: 74..86,
|
range: 118..130,
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("x"),
|
id: Name("x"),
|
||||||
range: 74..75,
|
range: 118..119,
|
||||||
},
|
},
|
||||||
annotation: Some(
|
annotation: Some(
|
||||||
Yield(
|
Yield(
|
||||||
ExprYield {
|
ExprYield {
|
||||||
range: 78..85,
|
range: 122..129,
|
||||||
value: Some(
|
value: Some(
|
||||||
NumberLiteral(
|
NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 84..85,
|
range: 128..129,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
@ -201,10 +201,10 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 89..92,
|
range: 133..136,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 89..92,
|
range: 133..136,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -214,16 +214,16 @@ Module(
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 97..122,
|
range: 141..166,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("k"),
|
id: Name("k"),
|
||||||
range: 101..102,
|
range: 145..146,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 102..104,
|
range: 146..148,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [],
|
args: [],
|
||||||
vararg: None,
|
vararg: None,
|
||||||
|
@ -233,11 +233,11 @@ Module(
|
||||||
returns: Some(
|
returns: Some(
|
||||||
Yield(
|
Yield(
|
||||||
ExprYield {
|
ExprYield {
|
||||||
range: 109..116,
|
range: 153..160,
|
||||||
value: Some(
|
value: Some(
|
||||||
NumberLiteral(
|
NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 115..116,
|
range: 159..160,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
@ -250,10 +250,10 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 119..122,
|
range: 163..166,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 119..122,
|
range: 163..166,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -263,33 +263,33 @@ Module(
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 127..156,
|
range: 171..200,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("m"),
|
id: Name("m"),
|
||||||
range: 131..132,
|
range: 175..176,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 132..151,
|
range: 176..195,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [
|
args: [
|
||||||
ParameterWithDefault {
|
ParameterWithDefault {
|
||||||
range: 133..150,
|
range: 177..194,
|
||||||
parameter: Parameter {
|
parameter: Parameter {
|
||||||
range: 133..150,
|
range: 177..194,
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("x"),
|
id: Name("x"),
|
||||||
range: 133..134,
|
range: 177..178,
|
||||||
},
|
},
|
||||||
annotation: Some(
|
annotation: Some(
|
||||||
YieldFrom(
|
YieldFrom(
|
||||||
ExprYieldFrom {
|
ExprYieldFrom {
|
||||||
range: 137..149,
|
range: 181..193,
|
||||||
value: NumberLiteral(
|
value: NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 148..149,
|
range: 192..193,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
@ -310,10 +310,10 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 153..156,
|
range: 197..200,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 153..156,
|
range: 197..200,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -323,16 +323,16 @@ Module(
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
StmtFunctionDef {
|
StmtFunctionDef {
|
||||||
range: 161..191,
|
range: 205..235,
|
||||||
is_async: false,
|
is_async: false,
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
name: Identifier {
|
name: Identifier {
|
||||||
id: Name("o"),
|
id: Name("o"),
|
||||||
range: 165..166,
|
range: 209..210,
|
||||||
},
|
},
|
||||||
type_params: None,
|
type_params: None,
|
||||||
parameters: Parameters {
|
parameters: Parameters {
|
||||||
range: 166..168,
|
range: 210..212,
|
||||||
posonlyargs: [],
|
posonlyargs: [],
|
||||||
args: [],
|
args: [],
|
||||||
vararg: None,
|
vararg: None,
|
||||||
|
@ -342,10 +342,10 @@ Module(
|
||||||
returns: Some(
|
returns: Some(
|
||||||
YieldFrom(
|
YieldFrom(
|
||||||
ExprYieldFrom {
|
ExprYieldFrom {
|
||||||
range: 173..185,
|
range: 217..229,
|
||||||
value: NumberLiteral(
|
value: NumberLiteral(
|
||||||
ExprNumberLiteral {
|
ExprNumberLiteral {
|
||||||
range: 184..185,
|
range: 228..229,
|
||||||
value: Int(
|
value: Int(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
@ -357,10 +357,140 @@ Module(
|
||||||
body: [
|
body: [
|
||||||
Expr(
|
Expr(
|
||||||
StmtExpr {
|
StmtExpr {
|
||||||
range: 188..191,
|
range: 232..235,
|
||||||
value: EllipsisLiteral(
|
value: EllipsisLiteral(
|
||||||
ExprEllipsisLiteral {
|
ExprEllipsisLiteral {
|
||||||
range: 188..191,
|
range: 232..235,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 236..315,
|
||||||
|
is_async: true,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("outer"),
|
||||||
|
range: 246..251,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 251..253,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: None,
|
||||||
|
body: [
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 259..284,
|
||||||
|
is_async: false,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("f"),
|
||||||
|
range: 263..264,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 264..266,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 271..278,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 277..278,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 281..284,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 281..284,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FunctionDef(
|
||||||
|
StmtFunctionDef {
|
||||||
|
range: 289..315,
|
||||||
|
is_async: false,
|
||||||
|
decorator_list: [],
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("g"),
|
||||||
|
range: 293..294,
|
||||||
|
},
|
||||||
|
type_params: None,
|
||||||
|
parameters: Parameters {
|
||||||
|
range: 294..310,
|
||||||
|
posonlyargs: [],
|
||||||
|
args: [
|
||||||
|
ParameterWithDefault {
|
||||||
|
range: 295..309,
|
||||||
|
parameter: Parameter {
|
||||||
|
range: 295..309,
|
||||||
|
name: Identifier {
|
||||||
|
id: Name("arg"),
|
||||||
|
range: 295..298,
|
||||||
|
},
|
||||||
|
annotation: Some(
|
||||||
|
Await(
|
||||||
|
ExprAwait {
|
||||||
|
range: 301..308,
|
||||||
|
value: NumberLiteral(
|
||||||
|
ExprNumberLiteral {
|
||||||
|
range: 307..308,
|
||||||
|
value: Int(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
default: None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vararg: None,
|
||||||
|
kwonlyargs: [],
|
||||||
|
kwarg: None,
|
||||||
|
},
|
||||||
|
returns: None,
|
||||||
|
body: [
|
||||||
|
Expr(
|
||||||
|
StmtExpr {
|
||||||
|
range: 312..315,
|
||||||
|
value: EllipsisLiteral(
|
||||||
|
ExprEllipsisLiteral {
|
||||||
|
range: 312..315,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
Loading…
Add table
Add a link
Reference in a new issue