mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[ty] Don't warn yield
not in function when yield
is in function (#18008)
This commit is contained in:
parent
d37592175f
commit
02fd48132c
7 changed files with 87 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue