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