@@ -156,6 +156,92 @@ class B2(A[T]):
156
156
def f(self: A[bytes]) -> bytes: ...
157
157
def f(self): ...
158
158
159
+ class C(A[int]):
160
+ def f(self) -> int: ...
161
+
162
+ class D(A[str]):
163
+ def f(self) -> int: ... # E: Signature of "f" incompatible with supertype "A" \
164
+ # N: Superclass: \
165
+ # N: @overload \
166
+ # N: def f(self) -> str \
167
+ # N: Subclass: \
168
+ # N: def f(self) -> int
169
+
170
+ class E(A[T]):
171
+ def f(self) -> int: ... # E: Signature of "f" incompatible with supertype "A" \
172
+ # N: Superclass: \
173
+ # N: @overload \
174
+ # N: def f(self) -> int \
175
+ # N: @overload \
176
+ # N: def f(self) -> str \
177
+ # N: Subclass: \
178
+ # N: def f(self) -> int
179
+
180
+
181
+ class F(A[bytes]):
182
+ # Note there's an argument to be made that this is actually compatible with the supertype
183
+ def f(self) -> bytes: ... # E: Signature of "f" incompatible with supertype "A" \
184
+ # N: Superclass: \
185
+ # N: @overload \
186
+ # N: def f(self) -> int \
187
+ # N: @overload \
188
+ # N: def f(self) -> str \
189
+ # N: Subclass: \
190
+ # N: def f(self) -> bytes
191
+
192
+ class G(A):
193
+ def f(self): ...
194
+
195
+ class H(A[int]):
196
+ def f(self): ...
197
+
198
+ class I(A[int]):
199
+ def f(*args): ...
200
+
201
+ class J(A[int]):
202
+ def f(self, arg) -> int: ... # E: Signature of "f" incompatible with supertype "A" \
203
+ # N: Superclass: \
204
+ # N: @overload \
205
+ # N: def f(self) -> int \
206
+ # N: Subclass: \
207
+ # N: def f(self, arg: Any) -> int
208
+
209
+ [builtins fixtures/tuple.pyi]
210
+
211
+ [case testSelfTypeOverrideCompatibilityTypeVar-xfail]
212
+ from typing import overload, TypeVar, Union
213
+
214
+ AT = TypeVar("AT", bound="A")
215
+
216
+ class A:
217
+ @overload
218
+ def f(self: AT, x: int) -> AT: ...
219
+ @overload
220
+ def f(self, x: str) -> None: ...
221
+ @overload
222
+ def f(self: AT) -> bytes: ...
223
+ def f(*a, **kw): ...
224
+
225
+ class B(A):
226
+ @overload # E: Signature of "f" incompatible with supertype "A" \
227
+ # N: Superclass: \
228
+ # N: @overload \
229
+ # N: def f(self, x: int) -> B \
230
+ # N: @overload \
231
+ # N: def f(self, x: str) -> None \
232
+ # N: @overload \
233
+ # N: def f(self) -> bytes \
234
+ # N: Subclass: \
235
+ # N: @overload \
236
+ # N: def f(self, x: int) -> B \
237
+ # N: @overload \
238
+ # N: def f(self, x: str) -> None
239
+ def f(self, x: int) -> B: ...
240
+ @overload
241
+ def f(self, x: str) -> None: ...
242
+ def f(*a, **kw): ...
243
+ [builtins fixtures/dict.pyi]
244
+
159
245
[case testSelfTypeSuper]
160
246
from typing import TypeVar, cast
161
247
0 commit comments