[ty] Don't warn yield not in function when yield is in function (#18008)
This commit is contained in:
@@ -298,25 +298,25 @@ python-version = "3.12"
|
||||
```
|
||||
|
||||
```py
|
||||
# error: [invalid-type-form] "`yield` expressions are not allowed in type expressions"
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a TypeVar bound"
|
||||
# error: [invalid-syntax] "`yield` statement outside of a function"
|
||||
type X[T: (yield 1)] = int
|
||||
def _():
|
||||
# error: [invalid-type-form] "`yield` expressions are not allowed in type expressions"
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a TypeVar bound"
|
||||
type X[T: (yield 1)] = int
|
||||
|
||||
# error: [invalid-type-form] "`yield` expressions are not allowed in type expressions"
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a type alias"
|
||||
# error: [invalid-syntax] "`yield` statement outside of a function"
|
||||
type Y = (yield 1)
|
||||
def _():
|
||||
# error: [invalid-type-form] "`yield` expressions are not allowed in type expressions"
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a type alias"
|
||||
type Y = (yield 1)
|
||||
|
||||
# error: [invalid-type-form] "Named expressions are not allowed in type expressions"
|
||||
# error: [invalid-syntax] "named expression cannot be used within a generic definition"
|
||||
def f[T](x: int) -> (y := 3):
|
||||
return x
|
||||
|
||||
# error: [invalid-syntax] "`yield from` statement outside of a function"
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a generic definition"
|
||||
class C[T]((yield from [object])):
|
||||
pass
|
||||
def _():
|
||||
# error: [invalid-syntax] "yield expression cannot be used within a generic definition"
|
||||
class C[T]((yield from [object])):
|
||||
pass
|
||||
```
|
||||
|
||||
## `await` outside async function
|
||||
|
||||
Reference in New Issue
Block a user