-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathdeps-generics.test
More file actions
204 lines (165 loc) · 3.66 KB
/
deps-generics.test
File metadata and controls
204 lines (165 loc) · 3.66 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
-- Test cases for generating fine-grained dependencies involving generics.
--
-- The dependencies are used for fined-grained incremental checking.
--
-- See the comment at the top of deps.test for more documentation.
[case testGenericFunction]
from typing import TypeVar
T = TypeVar('T')
class A: pass
def f(x: T) -> T:
y: T
z: A
return x
[out]
<m.A> -> m.A, m.f
<m.T> -> <m.f>, m.f
[case testGenericClass]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]): pass
class B: pass
def f() -> None:
a: A[B]
[out]
<m.A> -> m.A, m.f
<m.B> -> m.B, m.f
<m.T> -> m.A
[case testGenericClassWithMembers]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
def g(self, a: T) -> None:
self.x = a
def f(self) -> T:
return self.x
[out]
<m.A.x> -> m.A.f, m.A.g
<m.A> -> m.A
<m.T> -> <m.A.f>, <m.A.g>, <m.A.x>, m.A, m.A.f, m.A.g
[case testGenericClassInit]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
def __init__(self, a: T) -> None:
self.x = a
class B: pass
def f() -> None:
a = A(B())
[out]
<m.A.__init__> -> m.f
<m.A.__new__> -> m.f
<m.A.x> -> m.A.__init__
<m.A> -> m.A, m.f
<m.B.__init__> -> m.f
<m.B.__new__> -> m.f
<m.B> -> m.B, m.f
<m.T> -> <m.A.__init__>, <m.A.x>, m.A, m.A.__init__
[case testGenericMethod]
from typing import TypeVar
T = TypeVar('T')
class A:
def f(self, x: T) -> T:
return x
[out]
<m.A> -> m.A
<m.T> -> <m.A.f>, m.A.f
[case testGenericBaseClass]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]): pass
class B(A[C]): pass
class C: pass
[out]
<m.A.(abstract)> -> <m.B.__init__>, m
<m.A.__init__> -> <m.B.__init__>
<m.A.__new__> -> <m.B.__new__>
<m.A> -> m, m.A, m.B
<m.B> -> m.B
<m.C> -> m, m.B, m.C
<m.T> -> m.A
[case testGenericBaseClass2]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]): pass
class B(A[T]): pass
[out]
<m.A.(abstract)> -> <m.B.__init__>, m
<m.A.__init__> -> <m.B.__init__>
<m.A.__new__> -> <m.B.__new__>
<m.A> -> m, m.A, m.B
<m.B> -> m.B
<m.T> -> m, m.A, m.B
[case testTypeVarBound]
from typing import TypeVar, Tuple
class A: pass
class B: pass
T = TypeVar('T', bound=Tuple[A, B])
def f(x: T) -> T:
return x
[builtins fixtures/tuple.pyi]
[out]
<m.A> -> <m.T>, <m.f>, m, m.A, m.f
<m.B> -> <m.T>, <m.f>, m, m.B, m.f
<m.T> -> <m.f>, m.f
[case testTypeVarBoundOperations]
from typing import TypeVar, Tuple
class A:
def f(self) -> None: pass
def __add__(self, other: int) -> int: pass
T = TypeVar('T', bound=A)
def f(x: T) -> None:
x.f()
x + 1
[out]
<m.A.__add__> -> m.f
<m.A.f> -> m.f
<m.A> -> <m.T>, <m.f>, m, m.A, m.f
<m.T> -> <m.f>, m.f
[case testTypeVarValues]
from typing import TypeVar
class A: pass
class B: pass
class C: pass
class D: pass
T = TypeVar('T', A, B)
S = TypeVar('S', C, D)
def f(x: T, y: S) -> S:
pass
[out]
<m.A> -> <m.T>, <m.f>, m, m.A, m.f
<m.B> -> <m.T>, <m.f>, m, m.B, m.f
<m.C> -> <m.S>, <m.f>, m, m.C, m.f
<m.D> -> <m.S>, <m.f>, m, m.D, m.f
<m.S> -> <m.f>, m.f
<m.T> -> <m.f>, m.f
[case testTypeVarValuesMethod]
from typing import TypeVar, Generic
class C: pass
class D: pass
S = TypeVar('S', C, D)
class G(Generic[S]):
def f(self) -> S:
pass
[out]
<m.C> -> <m.G.f>, <m.S>, m, m.C, m.G.f
<m.D> -> <m.G.f>, <m.S>, m, m.D, m.G.f
<m.G> -> m.G
<m.S> -> <m.G.f>, m.G, m.G.f
[case testTypeVarValuesMethodAttr]
from typing import TypeVar, Generic
class A:
x: int
class B:
x: int
T = TypeVar('T', A, B)
class G(Generic[T]):
def f(self, x: T) -> None:
x.x
[out]
<m.A.x> -> m.G.f
<m.A> -> <m.G.f>, <m.T>, m, m.A, m.G.f
<m.B.x> -> m.G.f
<m.B> -> <m.G.f>, <m.T>, m, m.B, m.G.f
<m.G> -> m.G
<m.T> -> <m.G.f>, m.G, m.G.f