| 1 |
[case testPEP695TypeAlias] |
| 2 |
# comment |
| 3 |
type A[T] = C[T] |
| 4 |
[out] |
| 5 |
MypyFile:1( |
| 6 |
TypeAliasStmt:2( |
| 7 |
NameExpr(A) |
| 8 |
TypeParam( |
| 9 |
T) |
| 10 |
LambdaExpr:2( |
| 11 |
Block:-1( |
| 12 |
ReturnStmt:2( |
| 13 |
IndexExpr:2( |
| 14 |
NameExpr(C) |
| 15 |
NameExpr(T))))))) |
| 16 |
|
| 17 |
[case testPEP695GenericFunction] |
| 18 |
# comment |
| 19 |
|
| 20 |
def f[T](): pass |
| 21 |
def g[T: str](): pass |
| 22 |
def h[T: (int, str)](): pass |
| 23 |
[out] |
| 24 |
MypyFile:1( |
| 25 |
FuncDef:3( |
| 26 |
f |
| 27 |
TypeParam( |
| 28 |
T) |
| 29 |
Block:3( |
| 30 |
PassStmt:3())) |
| 31 |
FuncDef:4( |
| 32 |
g |
| 33 |
TypeParam( |
| 34 |
T |
| 35 |
str?) |
| 36 |
Block:4( |
| 37 |
PassStmt:4())) |
| 38 |
FuncDef:5( |
| 39 |
h |
| 40 |
TypeParam( |
| 41 |
T |
| 42 |
Values( |
| 43 |
int? |
| 44 |
str?)) |
| 45 |
Block:5( |
| 46 |
PassStmt:5()))) |
| 47 |
|
| 48 |
[case testPEP695ParamSpec] |
| 49 |
# comment |
| 50 |
|
| 51 |
def f[**P](): pass |
| 52 |
class C[T: int, **P]: pass |
| 53 |
[out] |
| 54 |
MypyFile:1( |
| 55 |
FuncDef:3( |
| 56 |
f |
| 57 |
TypeParam( |
| 58 |
**P) |
| 59 |
Block:3( |
| 60 |
PassStmt:3())) |
| 61 |
ClassDef:4( |
| 62 |
C |
| 63 |
TypeParam( |
| 64 |
T |
| 65 |
int?) |
| 66 |
TypeParam( |
| 67 |
**P) |
| 68 |
PassStmt:4())) |
| 69 |
|
| 70 |
[case testPEP695TypeVarTuple] |
| 71 |
# comment |
| 72 |
|
| 73 |
def f[*Ts](): pass |
| 74 |
class C[T: int, *Ts]: pass |
| 75 |
[out] |
| 76 |
MypyFile:1( |
| 77 |
FuncDef:3( |
| 78 |
f |
| 79 |
TypeParam( |
| 80 |
*Ts) |
| 81 |
Block:3( |
| 82 |
PassStmt:3())) |
| 83 |
ClassDef:4( |
| 84 |
C |
| 85 |
TypeParam( |
| 86 |
T |
| 87 |
int?) |
| 88 |
TypeParam( |
| 89 |
*Ts) |
| 90 |
PassStmt:4())) |