mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +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 K[T: (yield 1)]: ... # yield 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 g[T](arg: (x := 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 v[*Ts = (x := 1)](): ... # named expr in TypeVarTuple 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 m(x: (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 Y = (yield 1) # yield 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue