@@ -2528,3 +2528,41 @@ class EmptyProto(Protocol): ...
2528
2528
def hh(h: EmptyProto) -> None: pass
2529
2529
hh(None)
2530
2530
[builtins fixtures/tuple.pyi]
2531
+
2532
+
2533
+ [case testPartialTypeProtocol]
2534
+ from typing import Protocol
2535
+
2536
+ class Flapper(Protocol):
2537
+ def flap(self) -> int: ...
2538
+
2539
+ class Blooper:
2540
+ flap = None
2541
+
2542
+ def bloop(self, x: Flapper) -> None:
2543
+ reveal_type([self, x]) # N: Revealed type is 'builtins.list[builtins.object*]'
2544
+
2545
+ class Gleemer:
2546
+ flap = [] # E: Need type annotation for 'flap' (hint: "flap: List[<type>] = ...")
2547
+
2548
+ def gleem(self, x: Flapper) -> None:
2549
+ reveal_type([self, x]) # N: Revealed type is 'builtins.list[builtins.object*]'
2550
+ [builtins fixtures/tuple.pyi]
2551
+
2552
+
2553
+ [case testPartialTypeProtocolHashable]
2554
+ # flags: --no-strict-optional
2555
+ from typing import Protocol
2556
+
2557
+ class Hashable(Protocol):
2558
+ def __hash__(self) -> int: ...
2559
+
2560
+ class ObjectHashable:
2561
+ def __hash__(self) -> int: ...
2562
+
2563
+ class DataArray(ObjectHashable):
2564
+ __hash__ = None
2565
+
2566
+ def f(self, x: Hashable) -> None:
2567
+ reveal_type([self, x]) # N: Revealed type is 'builtins.list[builtins.object*]'
2568
+ [builtins fixtures/tuple.pyi]
0 commit comments