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