Skip to content

Commit f1414f2

Browse files
committed
Add testSelfTypeOverrideCompatibilitySelfTypeVar (not my work: taken from python#15045 for comparison)
1 parent 6b1573f commit f1414f2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test-data/unit/check-selftype.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,26 @@ class B(A):
266266
def f(*a, **kw): ...
267267
[builtins fixtures/dict.pyi]
268268

269+
[case testSelfTypeOverrideCompatibilitySelfTypeVar]
270+
from typing import Any, Generic, Self, TypeVar, overload
271+
272+
T_co = TypeVar('T_co', covariant=True)
273+
274+
class Config(Generic[T_co]):
275+
@overload
276+
def get(self, instance: None) -> Self: ...
277+
@overload
278+
def get(self, instance: Any) -> T_co: ...
279+
def get(self, *a, **kw): ...
280+
281+
class MultiConfig(Config[T_co]):
282+
@overload
283+
def get(self, instance: None) -> Self: ...
284+
@overload
285+
def get(self, instance: Any) -> T_co: ...
286+
def get(self, *a, **kw): ...
287+
[builtins fixtures/dict.pyi]
288+
269289
[case testSelfTypeSuper]
270290
from typing import TypeVar, cast
271291

0 commit comments

Comments
 (0)