@@ -70,6 +70,9 @@ MaybeNone: TypeAlias = Any # stable
70
70
# def foo(x: int | None | _SentinelType = ...) -> None: ...
71
71
sentinel : Any
72
72
73
+ class SupportsBool (Protocol ):
74
+ def __bool__ (self ) -> bool : ...
75
+
73
76
# stable
74
77
class IdentityFunction (Protocol ):
75
78
def __call__ (self , x : _T , / ) -> _T : ...
@@ -85,16 +88,16 @@ class SupportsAnext(Protocol[_T_co]):
85
88
# Comparison protocols
86
89
87
90
class SupportsDunderLT (Protocol [_T_contra ]):
88
- def __lt__ (self , other : _T_contra , / ) -> bool : ...
91
+ def __lt__ (self , other : _T_contra , / ) -> SupportsBool : ...
89
92
90
93
class SupportsDunderGT (Protocol [_T_contra ]):
91
- def __gt__ (self , other : _T_contra , / ) -> bool : ...
94
+ def __gt__ (self , other : _T_contra , / ) -> SupportsBool : ...
92
95
93
96
class SupportsDunderLE (Protocol [_T_contra ]):
94
- def __le__ (self , other : _T_contra , / ) -> bool : ...
97
+ def __le__ (self , other : _T_contra , / ) -> SupportsBool : ...
95
98
96
99
class SupportsDunderGE (Protocol [_T_contra ]):
97
- def __ge__ (self , other : _T_contra , / ) -> bool : ...
100
+ def __ge__ (self , other : _T_contra , / ) -> SupportsBool : ...
98
101
99
102
class SupportsAllComparisons (
100
103
SupportsDunderLT [Any ], SupportsDunderGT [Any ], SupportsDunderLE [Any ], SupportsDunderGE [Any ], Protocol
@@ -155,17 +158,17 @@ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
155
158
# instead, if you require the __contains__ method.
156
159
# See https://github.com/python/typeshed/issues/11822.
157
160
class SupportsGetItem (Protocol [_KT_contra , _VT_co ]):
158
- def __contains__ (self , x : Any , / ) -> bool : ...
161
+ def __contains__ (self , x : Any , / ) -> SupportsBool : ...
159
162
def __getitem__ (self , key : _KT_contra , / ) -> _VT_co : ...
160
163
161
164
# stable
162
165
class SupportsContainsAndGetItem (Protocol [_KT_contra , _VT_co ]):
163
- def __contains__ (self , x : Any , / ) -> bool : ...
166
+ def __contains__ (self , x : Any , / ) -> SupportsBool : ...
164
167
def __getitem__ (self , key : _KT_contra , / ) -> _VT_co : ...
165
168
166
169
# stable
167
170
class SupportsItemAccess (Protocol [_KT_contra , _VT ]):
168
- def __contains__ (self , x : Any , / ) -> bool : ...
171
+ def __contains__ (self , x : Any , / ) -> SupportsBool : ...
169
172
def __getitem__ (self , key : _KT_contra , / ) -> _VT : ...
170
173
def __setitem__ (self , key : _KT_contra , value : _VT , / ) -> None : ...
171
174
def __delitem__ (self , key : _KT_contra , / ) -> None : ...
@@ -287,7 +290,7 @@ class IndexableBuffer(Buffer, Protocol):
287
290
def __getitem__ (self , i : int , / ) -> int : ...
288
291
289
292
class SupportsGetItemBuffer (SliceableBuffer , IndexableBuffer , Protocol ):
290
- def __contains__ (self , x : Any , / ) -> bool : ...
293
+ def __contains__ (self , x : Any , / ) -> SupportsBool : ...
291
294
@overload
292
295
def __getitem__ (self , slice : slice , / ) -> Sequence [int ]: ...
293
296
@overload
0 commit comments