mirror of
https://github.com/astral-sh/ruff.git
synced 2026-12-04 02:03:58 +08:00
Clarify the diagnostic for unparenthesized yield expressions
This commit is contained in:
@@ -129,11 +129,11 @@ pub enum ParseErrorType {
|
||||
UnparenthesizedTupleExpression,
|
||||
/// An unparenthesized generator expression was found where it is not allowed.
|
||||
UnparenthesizedGeneratorExpression,
|
||||
/// An unparenthesized yield expression was found where it is not allowed.
|
||||
UnparenthesizedYieldExpression,
|
||||
|
||||
/// An invalid usage of a lambda expression was found.
|
||||
InvalidLambdaExpressionUsage,
|
||||
/// An invalid usage of a yield expression was found.
|
||||
InvalidYieldExpressionUsage,
|
||||
/// An invalid usage of a starred expression was found.
|
||||
InvalidStarredExpressionUsage,
|
||||
/// A star pattern was found outside a sequence pattern.
|
||||
@@ -254,8 +254,8 @@ impl std::fmt::Display for ParseErrorType {
|
||||
ParseErrorType::UnparenthesizedGeneratorExpression => {
|
||||
f.write_str("Unparenthesized generator expression cannot be used here")
|
||||
}
|
||||
ParseErrorType::InvalidYieldExpressionUsage => {
|
||||
f.write_str("Yield expression cannot be used here")
|
||||
ParseErrorType::UnparenthesizedYieldExpression => {
|
||||
f.write_str("Unparenthesized yield expression cannot be used here")
|
||||
}
|
||||
ParseErrorType::InvalidLambdaExpressionUsage => {
|
||||
f.write_str("Lambda expression cannot be used here")
|
||||
|
||||
@@ -412,7 +412,7 @@ impl<'src> Parser<'src> {
|
||||
if left_precedence > OperatorPrecedence::None
|
||||
|| !context.is_yield_expression_allowed()
|
||||
{
|
||||
self.add_error(ParseErrorType::InvalidYieldExpressionUsage, &expr);
|
||||
self.add_error(ParseErrorType::UnparenthesizedYieldExpression, &expr);
|
||||
}
|
||||
|
||||
return expr.into();
|
||||
|
||||
@@ -2396,7 +2396,7 @@ impl<'src> Parser<'src> {
|
||||
Expr::Named(_) => ParseErrorType::UnparenthesizedNamedExpression,
|
||||
Expr::Starred(_) => ParseErrorType::InvalidStarredExpressionUsage,
|
||||
Expr::Yield(_) | Expr::YieldFrom(_) => {
|
||||
ParseErrorType::InvalidYieldExpressionUsage
|
||||
ParseErrorType::UnparenthesizedYieldExpression
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
+2
-2
@@ -199,7 +199,7 @@ Module(
|
||||
|
|
||||
1 | x: *int = 1
|
||||
2 | x: yield a = 1
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | x: yield from b = 1
|
||||
4 | x: y := int = 1
|
||||
|
|
||||
@@ -209,7 +209,7 @@ Module(
|
||||
1 | x: *int = 1
|
||||
2 | x: yield a = 1
|
||||
3 | x: yield from b = 1
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | x: y := int = 1
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ Module(
|
||||
1 | assert False, *x
|
||||
2 | assert False, assert x
|
||||
3 | assert False, yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | assert False, x := 1
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ Module(
|
||||
1 | assert *x
|
||||
2 | assert assert x
|
||||
3 | assert yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | assert x := 1
|
||||
|
|
||||
|
||||
|
||||
+2
-2
@@ -312,7 +312,7 @@ Module(
|
||||
|
|
||||
1 | x = (*a and b,)
|
||||
2 | x = (42, *yield x)
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | x = (42, *yield from x)
|
||||
4 | x = (*lambda x: x,)
|
||||
|
|
||||
@@ -322,7 +322,7 @@ Module(
|
||||
1 | x = (*a and b,)
|
||||
2 | x = (42, *yield x)
|
||||
3 | x = (42, *yield from x)
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | x = (*lambda x: x,)
|
||||
5 | x = x := 1
|
||||
|
|
||||
|
||||
+2
-2
@@ -249,7 +249,7 @@ Module(
|
||||
|
|
||||
1 | x += *a and b
|
||||
2 | x += *yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | x += *yield from x
|
||||
4 | x += *lambda x: x
|
||||
|
|
||||
@@ -259,7 +259,7 @@ Module(
|
||||
1 | x += *a and b
|
||||
2 | x += *yield x
|
||||
3 | x += *yield from x
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | x += *lambda x: x
|
||||
5 | x += y := 1
|
||||
|
|
||||
|
||||
+2
-2
@@ -181,7 +181,7 @@ Module(
|
||||
2 | @(*x)
|
||||
3 | @((*x))
|
||||
4 | @yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | @yield from x
|
||||
6 | def foo(): ...
|
||||
|
|
||||
@@ -191,6 +191,6 @@ Module(
|
||||
3 | @((*x))
|
||||
4 | @yield x
|
||||
5 | @yield from x
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
6 | def foo(): ...
|
||||
|
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ Module(
|
||||
1 | try:
|
||||
2 | pass
|
||||
3 | except yield x:
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | pass
|
||||
5 | try:
|
||||
|
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ Module(
|
||||
|
||||
|
|
||||
1 | call(**yield x)
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
2 | call(** *x)
|
||||
3 | call(***x)
|
||||
|
|
||||
|
||||
+2
-2
@@ -214,7 +214,7 @@ Module(
|
||||
2 | call(x := 1 = 1)
|
||||
3 |
|
||||
4 | call(yield x)
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | call(yield from x)
|
||||
|
|
||||
|
||||
@@ -222,4 +222,4 @@ Module(
|
||||
|
|
||||
4 | call(yield x)
|
||||
5 | call(yield from x)
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+2
-2
@@ -230,7 +230,7 @@ Module(
|
||||
|
||||
|
|
||||
1 | call(x = yield y)
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
2 | call(x = yield from y)
|
||||
3 | call(x = *y)
|
||||
|
|
||||
@@ -239,7 +239,7 @@ Module(
|
||||
|
|
||||
1 | call(x = yield y)
|
||||
2 | call(x = yield from y)
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | call(x = *y)
|
||||
4 | call(x = (*y))
|
||||
|
|
||||
|
||||
+2
-2
@@ -190,7 +190,7 @@ Module(
|
||||
|
|
||||
1 | call(*data for data in iter)
|
||||
2 | call(*yield x)
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | call(*yield from x)
|
||||
|
|
||||
|
||||
@@ -199,7 +199,7 @@ Module(
|
||||
1 | call(*data for data in iter)
|
||||
2 | call(*yield x)
|
||||
3 | call(*yield from x)
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
|
||||
## Unsupported Syntax Errors
|
||||
|
||||
+1
-1
@@ -315,7 +315,7 @@ Module(
|
||||
|
|
||||
11 | # Invalid expression as per precedence
|
||||
12 | await yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
13 | await lambda x: x
|
||||
14 | await +x
|
||||
|
|
||||
|
||||
+1
-1
@@ -127,4 +127,4 @@ Module(
|
||||
1 | x + lambda y: y
|
||||
2 |
|
||||
3 | x - yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -131,4 +131,4 @@ Module(
|
||||
1 | x and lambda y: y
|
||||
2 |
|
||||
3 | x or yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -135,4 +135,4 @@ Module(
|
||||
1 | x not in lambda y: y
|
||||
2 |
|
||||
3 | x == yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+4
-4
@@ -901,7 +901,7 @@ Module(
|
||||
7 | # Invalid iter
|
||||
8 | {x: y for x in *y}
|
||||
9 | {x: y for x in yield y}
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
10 | {x: y for x in yield from y}
|
||||
11 | {x: y for x in lambda y: y}
|
||||
|
|
||||
@@ -911,7 +911,7 @@ Module(
|
||||
8 | {x: y for x in *y}
|
||||
9 | {x: y for x in yield y}
|
||||
10 | {x: y for x in yield from y}
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
11 | {x: y for x in lambda y: y}
|
||||
|
|
||||
|
||||
@@ -939,7 +939,7 @@ Module(
|
||||
13 | # Invalid if
|
||||
14 | {x: y for x in data if *y}
|
||||
15 | {x: y for x in data if yield y}
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
16 | {x: y for x in data if yield from y}
|
||||
17 | {x: y for x in data if lambda y: y}
|
||||
|
|
||||
@@ -949,7 +949,7 @@ Module(
|
||||
14 | {x: y for x in data if *y}
|
||||
15 | {x: y for x in data if yield y}
|
||||
16 | {x: y for x in data if yield from y}
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
17 | {x: y for x in data if lambda y: y}
|
||||
|
|
||||
|
||||
|
||||
+4
-4
@@ -366,7 +366,7 @@ Module(
|
||||
2 | x if *expr else y
|
||||
3 | x if lambda x: x else y
|
||||
4 | x if yield x else y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | x if yield from x else y
|
||||
|
|
||||
|
||||
@@ -375,7 +375,7 @@ Module(
|
||||
3 | x if lambda x: x else y
|
||||
4 | x if yield x else y
|
||||
5 | x if yield from x else y
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
6 |
|
||||
7 | # Invalid orelse expression
|
||||
|
|
||||
@@ -394,7 +394,7 @@ Module(
|
||||
7 | # Invalid orelse expression
|
||||
8 | x if expr else *orelse
|
||||
9 | x if expr else yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
10 | x if expr else yield from y
|
||||
|
|
||||
|
||||
@@ -403,4 +403,4 @@ Module(
|
||||
8 | x if expr else *orelse
|
||||
9 | x if expr else yield y
|
||||
10 | x if expr else yield from y
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+4
-4
@@ -1142,7 +1142,7 @@ Module(
|
||||
7 | # Invalid iter
|
||||
8 | [x for x in *y]
|
||||
9 | [x for x in yield y]
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
10 | [x for x in yield from y]
|
||||
11 | [x for x in lambda y: y]
|
||||
|
|
||||
@@ -1152,7 +1152,7 @@ Module(
|
||||
8 | [x for x in *y]
|
||||
9 | [x for x in yield y]
|
||||
10 | [x for x in yield from y]
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
11 | [x for x in lambda y: y]
|
||||
12 | [**x for x in [{1: 2}]]
|
||||
|
|
||||
@@ -1251,7 +1251,7 @@ Module(
|
||||
16 | # Invalid if
|
||||
17 | [x for x in data if *y]
|
||||
18 | [x for x in data if yield y]
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
19 | [x for x in data if yield from y]
|
||||
20 | [x for x in data if lambda y: y]
|
||||
|
|
||||
@@ -1261,7 +1261,7 @@ Module(
|
||||
17 | [x for x in data if *y]
|
||||
18 | [x for x in data if yield y]
|
||||
19 | [x for x in data if yield from y]
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
20 | [x for x in data if lambda y: y]
|
||||
21 | [*x if x else y for x in z]
|
||||
|
|
||||
|
||||
+4
-4
@@ -781,7 +781,7 @@ Module(
|
||||
7 | # Invalid iter
|
||||
8 | {x for x in *y}
|
||||
9 | {x for x in yield y}
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
10 | {x for x in yield from y}
|
||||
11 | {x for x in lambda y: y}
|
||||
|
|
||||
@@ -791,7 +791,7 @@ Module(
|
||||
8 | {x for x in *y}
|
||||
9 | {x for x in yield y}
|
||||
10 | {x for x in yield from y}
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
11 | {x for x in lambda y: y}
|
||||
|
|
||||
|
||||
@@ -819,7 +819,7 @@ Module(
|
||||
13 | # Invalid if
|
||||
14 | {x for x in data if *y}
|
||||
15 | {x for x in data if yield y}
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
16 | {x for x in data if yield from y}
|
||||
17 | {x for x in data if lambda y: y}
|
||||
|
|
||||
@@ -829,7 +829,7 @@ Module(
|
||||
14 | {x for x in data if *y}
|
||||
15 | {x for x in data if yield y}
|
||||
16 | {x for x in data if yield from y}
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
17 | {x for x in data if lambda y: y}
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -219,4 +219,4 @@ Module(
|
||||
2 | f"{*}"
|
||||
3 | f"{*x and y}"
|
||||
4 | f"{*yield x}"
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ Module(
|
||||
|
|
||||
1 | for x in *a and b: ...
|
||||
2 | for x in yield a: ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | for target in x := 1: ...
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -489,7 +489,7 @@ Module(
|
||||
4 | for *x | y in z: ...
|
||||
5 | for await x in z: ...
|
||||
6 | for yield x in y: ...
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
7 | for [x, 1, y, *["a"]] in z: ...
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ Module(
|
||||
1 | def foo() -> *int: ...
|
||||
2 | def foo() -> (*int): ...
|
||||
3 | def foo() -> yield x: ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
|
||||
## Semantic Syntax Errors
|
||||
|
||||
+1
-1
@@ -113,6 +113,6 @@ Module(
|
||||
3 | elif *x:
|
||||
4 | pass
|
||||
5 | elif yield x:
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
6 | pass
|
||||
|
|
||||
|
||||
+2
-2
@@ -135,7 +135,7 @@ Module(
|
||||
|
|
||||
1 | if *x: ...
|
||||
2 | if yield x: ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | if yield from x: ...
|
||||
|
|
||||
|
||||
@@ -144,4 +144,4 @@ Module(
|
||||
1 | if *x: ...
|
||||
2 | if yield x: ...
|
||||
3 | if yield from x: ...
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+2
-2
@@ -126,7 +126,7 @@ Module(
|
||||
|
||||
|
|
||||
1 | lambda x: yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
2 | lambda x: yield from y
|
||||
|
|
||||
|
||||
@@ -134,4 +134,4 @@ Module(
|
||||
|
|
||||
1 | lambda x: yield y
|
||||
2 | lambda x: yield from y
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -69,6 +69,6 @@ Module(
|
||||
|
||||
|
|
||||
1 | match yield foo:
|
||||
| ^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
2 | case _: ...
|
||||
|
|
||||
|
||||
+1
-1
@@ -235,4 +235,4 @@ Module(
|
||||
4 | case y if (*a): ...
|
||||
5 | match x:
|
||||
6 | case y if yield x: ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -224,6 +224,6 @@ Module(
|
||||
4 | match *x and y, z:
|
||||
5 | case _: ...
|
||||
6 | match yield x:
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
7 | case _: ...
|
||||
|
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ Module(
|
||||
|
|
||||
1 | def foo(arg: *int): ...
|
||||
2 | def foo(arg: yield int): ...
|
||||
| ^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | def foo(arg: x := int): ...
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -247,4 +247,4 @@ Module(
|
||||
1 | def foo(x=*int): ...
|
||||
2 | def foo(x=(*int)): ...
|
||||
3 | def foo(x=yield y): ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+1
-1
@@ -347,7 +347,7 @@ Module(
|
||||
2 | def foo(*args: (*tuple[int])): ...
|
||||
3 | def foo(*args: *int or str): ...
|
||||
4 | def foo(*args: *yield x): ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | # def foo(*args: **int): ...
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ Module(
|
||||
|
|
||||
1 | raise x from *y
|
||||
2 | raise x from yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | raise x from y := 1
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ Module(
|
||||
|
|
||||
1 | raise *x
|
||||
2 | raise yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | raise x := 1
|
||||
|
|
||||
|
||||
|
||||
+2
-2
@@ -168,7 +168,7 @@ Module(
|
||||
|
|
||||
1 | return *
|
||||
2 | return yield x
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | return yield from x
|
||||
4 | return x := 1
|
||||
|
|
||||
@@ -178,7 +178,7 @@ Module(
|
||||
1 | return *
|
||||
2 | return yield x
|
||||
3 | return yield from x
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | return x := 1
|
||||
5 | return *x and y
|
||||
|
|
||||
|
||||
+3
-3
@@ -1764,7 +1764,7 @@ Module(
|
||||
19 | with (x as f, *y): ...
|
||||
20 | with (*x, y as f): ...
|
||||
21 | with (x, yield y): ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
22 | with (x, yield y, z): ...
|
||||
23 | with (x, yield from y): ...
|
||||
|
|
||||
@@ -1774,7 +1774,7 @@ Module(
|
||||
20 | with (*x, y as f): ...
|
||||
21 | with (x, yield y): ...
|
||||
22 | with (x, yield y, z): ...
|
||||
| ^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
23 | with (x, yield from y): ...
|
||||
24 | with (x as f, y) as f: ...
|
||||
|
|
||||
@@ -1784,7 +1784,7 @@ Module(
|
||||
21 | with (x, yield y): ...
|
||||
22 | with (x, yield y, z): ...
|
||||
23 | with (x, yield from y): ...
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
24 | with (x as f, y) as f: ...
|
||||
25 | with (x for x in iter as y): ...
|
||||
|
|
||||
|
||||
+1
-1
@@ -220,4 +220,4 @@ Module(
|
||||
3 | t"{*}"
|
||||
4 | t"{*x and y}"
|
||||
5 | t"{*yield x}"
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ Module(
|
||||
|
|
||||
1 | type x = *y
|
||||
2 | type x = yield y
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | type x = yield from y
|
||||
4 | type x = x := 1
|
||||
|
|
||||
@@ -165,7 +165,7 @@ Module(
|
||||
1 | type x = *y
|
||||
2 | type x = yield y
|
||||
3 | type x = yield from y
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | type x = x := 1
|
||||
|
|
||||
|
||||
|
||||
+2
-2
@@ -269,7 +269,7 @@ Module(
|
||||
|
|
||||
1 | type X[T: *int] = int
|
||||
2 | type X[T: yield x] = int
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | type X[T: yield from x] = int
|
||||
4 | type X[T: x := int] = int
|
||||
|
|
||||
@@ -279,7 +279,7 @@ Module(
|
||||
1 | type X[T: *int] = int
|
||||
2 | type X[T: yield x] = int
|
||||
3 | type X[T: yield from x] = int
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | type X[T: x := int] = int
|
||||
|
|
||||
|
||||
|
||||
+2
-2
@@ -323,7 +323,7 @@ Module(
|
||||
|
|
||||
1 | type X[**P = *int] = int
|
||||
2 | type X[**P = yield x] = int
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | type X[**P = yield from x] = int
|
||||
4 | type X[**P = x := int] = int
|
||||
|
|
||||
@@ -333,7 +333,7 @@ Module(
|
||||
1 | type X[**P = *int] = int
|
||||
2 | type X[**P = yield x] = int
|
||||
3 | type X[**P = yield from x] = int
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | type X[**P = x := int] = int
|
||||
5 | type X[**P = *int] = int
|
||||
|
|
||||
|
||||
+2
-2
@@ -397,7 +397,7 @@ Module(
|
||||
|
|
||||
1 | type X[T = *int] = int
|
||||
2 | type X[T = yield x] = int
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | type X[T = (yield x)] = int
|
||||
4 | type X[T = yield from x] = int
|
||||
|
|
||||
@@ -407,7 +407,7 @@ Module(
|
||||
2 | type X[T = yield x] = int
|
||||
3 | type X[T = (yield x)] = int
|
||||
4 | type X[T = yield from x] = int
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | type X[T = x := int] = int
|
||||
6 | type X[T: int = *int] = int
|
||||
|
|
||||
|
||||
+2
-2
@@ -342,7 +342,7 @@ Module(
|
||||
1 | type X[*Ts = *int] = int
|
||||
2 | type X[*Ts = *int or str] = int
|
||||
3 | type X[*Ts = yield x] = int
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
4 | type X[*Ts = yield from x] = int
|
||||
5 | type X[*Ts = x := int] = int
|
||||
|
|
||||
@@ -352,7 +352,7 @@ Module(
|
||||
2 | type X[*Ts = *int or str] = int
|
||||
3 | type X[*Ts = yield x] = int
|
||||
4 | type X[*Ts = yield from x] = int
|
||||
| ^^^^^^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
5 | type X[*Ts = x := int] = int
|
||||
|
|
||||
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ Module(
|
||||
|
|
||||
1 | while *x: ...
|
||||
2 | while yield x: ...
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
3 | while a, b: ...
|
||||
4 | while a := 1, b: ...
|
||||
|
|
||||
|
||||
@@ -86,4 +86,4 @@ Module(
|
||||
|
||||
|
|
||||
1 | def f(): 1, yield 1
|
||||
| ^^^^^^^ Syntax Error: Yield expression cannot be used here
|
||||
| ^^^^^^^ Syntax Error: Unparenthesized yield expression cannot be used here
|
||||
|
||||
@@ -430,7 +430,7 @@ error[invalid-syntax-in-forward-annotation]: Syntax error in forward annotation
|
||||
--> src/mdtest_snippet.py:43:5
|
||||
|
|
||||
43 | m: "yield 1"
|
||||
| ^^^^^^^ Yield expression cannot be used here
|
||||
| ^^^^^^^ Unparenthesized yield expression cannot be used here
|
||||
help: Did you mean `typing.Literal["yield 1"]`?
|
||||
help: Wrap in `Literal[...]`
|
||||
|
|
||||
@@ -450,7 +450,7 @@ error[invalid-syntax-in-forward-annotation]: Syntax error in forward annotation
|
||||
--> src/mdtest_snippet.py:45:5
|
||||
|
|
||||
45 | n: "yield from 1"
|
||||
| ^^^^^^^^^^^^ Yield expression cannot be used here
|
||||
| ^^^^^^^^^^^^ Unparenthesized yield expression cannot be used here
|
||||
help: Did you mean `typing.Literal["yield from 1"]`?
|
||||
help: Wrap in `Literal[...]`
|
||||
|
|
||||
@@ -472,7 +472,7 @@ error[invalid-syntax-in-forward-annotation]: Syntax error in forward annotation
|
||||
55 | t: "list[yield from 1]"
|
||||
| -----^^^^^^^^^^^^-
|
||||
| |
|
||||
| Yield expression cannot be used here
|
||||
| Unparenthesized yield expression cannot be used here
|
||||
help: Did you mean `typing.Literal["list[yield from 1]"]`?
|
||||
help: Wrap in `Literal[...]`
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user