File tree 1 file changed +29
-0
lines changed 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,35 @@ reveal_type(X1.ft()) # E: Revealed type is 'Type[__main__.X]'
449
449
450
450
[builtins fixtures/property.pyi]
451
451
452
+ [case testSelfTypeProperSupertypeAttributeGeneric]
453
+ from typing import Callable, TypeVar, Generic
454
+ Q = TypeVar('Q', covariant=True)
455
+ class K(Generic[Q]):
456
+ q: Q
457
+ T = TypeVar('T')
458
+ class A(K[Q]):
459
+ @property
460
+ def g(self: K[object]) -> int: return 0
461
+ @property
462
+ def gt(self: K[T]) -> T: return self.q
463
+ f: Callable[[object], int]
464
+ ft: Callable[[T], T]
465
+
466
+ class B(A[Q]):
467
+ pass
468
+ a: A[int]
469
+ b: B[str]
470
+ reveal_type(a.g) # E: Revealed type is 'builtins.int'
471
+ --reveal_type(a.gt) # E: Revealed type is 'builtins.int'
472
+ reveal_type(a.f()) # E: Revealed type is 'builtins.int'
473
+ --reveal_type(a.ft()) # E: Revealed type is '__main__.A*[builtins.int]'
474
+ reveal_type(b.g) # E: Revealed type is 'builtins.int'
475
+ --reveal_type(b.gt) # E: Revealed type is '__main__.B*[builtins.str]'
476
+ reveal_type(b.f()) # E: Revealed type is 'builtins.int'
477
+ --reveal_type(b.ft()) # E: Revealed type is '__main__.B*[builtins.str]'
478
+
479
+ [builtins fixtures/property.pyi]
480
+
452
481
[case testSelfTypeNotSelfType]
453
482
# Friendlier error messages for common mistakes. See #2950
454
483
class A:
You can’t perform that action at this time.
0 commit comments