@@ -367,10 +367,11 @@ reveal_type(x.f) # E: Revealed type is 'builtins.int'
367
367
368
368
[case testSelfTypeProperSupertypeAttribute]
369
369
from typing import Callable, TypeVar
370
- T = TypeVar('T', bound=object)
371
- class A:
370
+ class K: pass
371
+ T = TypeVar('T', bound=K)
372
+ class A(K):
372
373
@property
373
- def g(self: object ) -> int: return 0
374
+ def g(self: K ) -> int: return 0
374
375
@property
375
376
def gt(self: T) -> T: return self
376
377
f: Callable[[object], int]
@@ -392,7 +393,7 @@ reveal_type(B().ft()) # E: Revealed type is '__main__.B*'
392
393
393
394
[case testSelfTypeProperSupertypeAttributeTuple]
394
395
from typing import Callable, TypeVar, Tuple
395
- T = TypeVar('T', bound=object )
396
+ T = TypeVar('T')
396
397
class A(Tuple[int, int]):
397
398
@property
398
399
def g(self: object) -> int: return 0
@@ -417,7 +418,7 @@ reveal_type(B().ft()) # E: Revealed type is 'Tuple[builtins.int, builtins.int,
417
418
418
419
[case testSelfTypeProperSupertypeAttributeMeta]
419
420
from typing import Callable, TypeVar, Type
420
- T = TypeVar('T', bound=object )
421
+ T = TypeVar('T')
421
422
class A(type):
422
423
@property
423
424
def g(cls: object) -> int: return 0
@@ -429,17 +430,18 @@ class A(type):
429
430
class B(A):
430
431
pass
431
432
432
- class X(metaclass=B): pass
433
+ class X(metaclass=B):
434
+ def __init__(self, x: int) -> None: pass
433
435
class Y(X): pass
434
436
X1: Type[X]
435
437
reveal_type(X.g) # E: Revealed type is 'builtins.int'
436
- reveal_type(X.gt) # E: Revealed type is 'def () -> __main__.X'
438
+ reveal_type(X.gt) # E: Revealed type is 'def (x: builtins.int ) -> __main__.X'
437
439
reveal_type(X.f()) # E: Revealed type is 'builtins.int'
438
- reveal_type(X.ft()) # E: Revealed type is 'def () -> __main__.X'
440
+ reveal_type(X.ft()) # E: Revealed type is 'def (x: builtins.int ) -> __main__.X'
439
441
reveal_type(Y.g) # E: Revealed type is 'builtins.int'
440
- reveal_type(Y.gt) # E: Revealed type is 'def () -> __main__.Y'
442
+ reveal_type(Y.gt) # E: Revealed type is 'def (x: builtins.int ) -> __main__.Y'
441
443
reveal_type(Y.f()) # E: Revealed type is 'builtins.int'
442
- reveal_type(Y.ft()) # E: Revealed type is 'def () -> __main__.Y'
444
+ reveal_type(Y.ft()) # E: Revealed type is 'def (x: builtins.int ) -> __main__.Y'
443
445
reveal_type(X1.g) # E: Revealed type is 'builtins.int'
444
446
reveal_type(X1.gt) # E: Revealed type is 'Type[__main__.X]'
445
447
reveal_type(X1.f()) # E: Revealed type is 'builtins.int'
0 commit comments