mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 15:44:22 -05:00
Add support for PEP 696 syntax (#11120)
This commit is contained in:
@@ -29,9 +29,15 @@ class Test(A, B):
|
||||
# TypeVar
|
||||
class Test[T](): ...
|
||||
|
||||
# TypeVar with default
|
||||
class Test[T = str](): ...
|
||||
|
||||
# TypeVar with bound
|
||||
class Test[T: str](): ...
|
||||
|
||||
# TypeVar with bound and default
|
||||
class Test[T: int | str = int](): ...
|
||||
|
||||
# TypeVar with tuple bound
|
||||
class Test[T: (str, bytes)](): ...
|
||||
|
||||
@@ -44,9 +50,18 @@ class Test[T, U,](): ...
|
||||
# TypeVarTuple
|
||||
class Test[*Ts](): ...
|
||||
|
||||
# TypeVarTuple with default
|
||||
class Test[*Ts = Unpack[tuple[int, str]]](): ...
|
||||
|
||||
# TypeVarTuple with starred default
|
||||
class Test[*Ts = *tuple[int, str]](): ...
|
||||
|
||||
# ParamSpec
|
||||
class Test[**P](): ...
|
||||
|
||||
# ParamSpec with default
|
||||
class Test[**P = [int, str]](): ...
|
||||
|
||||
# Mixed types
|
||||
class Test[X, Y: str, *U, **P]():
|
||||
pass
|
||||
|
||||
@@ -7,6 +7,10 @@ type X[T] = list[T] | set[T]
|
||||
type X[T, *Ts, **P] = (T, Ts, P)
|
||||
type X[T: int, *Ts, **P] = (T, Ts, P)
|
||||
type X[T: (int, str), *Ts, **P] = (T, Ts, P)
|
||||
type X[T = int] = T | str
|
||||
type X[T: int | str = int] = T | int | str
|
||||
type X[*Ts = *tuple[int, str]] = tuple[int, *Ts, str]
|
||||
type X[**P = [int, str]] = Callable[P, str]
|
||||
|
||||
# Soft keyword as alias name
|
||||
type type = int
|
||||
|
||||
Reference in New Issue
Block a user