-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path_operator.pyi
More file actions
406 lines (349 loc) · 13.9 KB
/
_operator.pyi
File metadata and controls
406 lines (349 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
import sys
from _typeshed import SupportsGetItem
from collections.abc import Callable, Iterable, MutableMapping, MutableSequence, Sequence
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, TypeAlias, TypeIs
_R = TypeVar("_R")
_T = TypeVar("_T")
_T_contra = TypeVar("_T_contra", contravariant=True)
_U = TypeVar("_U")
_U_co = TypeVar("_U_co", covariant=True)
_T_co = TypeVar("_T_co", covariant=True)
_K = TypeVar("_K")
_V = TypeVar("_V")
_P = ParamSpec("_P")
# The following protocols return "Any" instead of bool, since the comparison
# operators can be overloaded to return an arbitrary object. For example,
# the numpy.array comparison dunders return another numpy.array.
@type_check_only
class _SupportsDunderLT(Protocol):
def __lt__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderGT(Protocol):
def __gt__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderLE(Protocol):
def __le__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderGE(Protocol):
def __ge__(self, other: Any, /) -> Any: ...
_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
@type_check_only
class _SupportsInversion(Protocol[_T_co]):
def __invert__(self) -> _T_co: ...
@type_check_only
class _SupportsNeg(Protocol[_T_co]):
def __neg__(self) -> _T_co: ...
@type_check_only
class _SupportsAdd(Protocol[_T_contra, _U_co]):
def __add__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRAdd(Protocol[_T_contra, _U_co]):
def __radd__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsPos(Protocol[_T_co]):
def __pos__(self) -> _T_co: ...
@type_check_only
class _SupportsAnd(Protocol[_T_contra, _U_co]):
def __and__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRAnd(Protocol[_T_contra, _U_co]):
def __rand__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsConcat(SupportsGetItem[Any, Any], _SupportsAdd[_T_contra, _U_co], Protocol[_T_contra, _U_co]): ...
@type_check_only
class _SupportsRConcat(SupportsGetItem[Any, Any], _SupportsRAdd[_T_contra, _U_co], Protocol[_T_contra, _U_co]): ...
@type_check_only
class _SupportsFloorDiv(Protocol[_T_contra, _U_co]):
def __floordiv__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRFloorDiv(Protocol[_T_contra, _U_co]):
def __rfloordiv__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsLShift(Protocol[_T_contra, _U_co]):
def __lshift__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRLShift(Protocol[_T_contra, _U_co]):
def __rlshift__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsMod(Protocol[_T_contra, _U_co]):
def __mod__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRMod(Protocol[_T_contra, _U_co]):
def __rmod__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsMul(Protocol[_T_contra, _U_co]):
def __mul__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRMul(Protocol[_T_contra, _U_co]):
def __rmul__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsMatMul(Protocol[_T_contra, _U_co]):
def __matmul__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRMatMul(Protocol[_T_contra, _U_co]):
def __rmatmul__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsOr(Protocol[_T_contra, _U_co]):
def __or__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsROr(Protocol[_T_contra, _U_co]):
def __ror__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsPow(Protocol[_T_contra, _U_co]):
def __pow__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRPow(Protocol[_T_contra, _U_co]):
def __rpow__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRShift(Protocol[_T_contra, _U_co]):
def __rshift__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRRShift(Protocol[_T_contra, _U_co]):
def __rrshift__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsSub(Protocol[_T_contra, _U_co]):
def __sub__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRSub(Protocol[_T_contra, _U_co]):
def __rsub__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsTrueDiv(Protocol[_T_contra, _U_co]):
def __truediv__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRTrueDiv(Protocol[_T_contra, _U_co]):
def __rtruediv__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsXor(Protocol[_T_contra, _U_co]):
def __xor__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsRXor(Protocol[_T_contra, _U_co]):
def __rxor__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsContains(Protocol[_T_contra, _U_co]):
def __contains__(self, other: _T_contra, /) -> _U_co: ...
@type_check_only
class _SupportsIAdd(Protocol[_T_contra, _U_co]):
def __iadd__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIAnd(Protocol[_T_contra, _U_co]):
def __iand__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIConcat(SupportsGetItem[Any, Any], _SupportsIAdd[_T_contra, _U_co], Protocol[_T_contra, _U_co]): ...
@type_check_only
class _SupportsIFloorDiv(Protocol[_T_contra, _U_co]):
def __ifloordiv__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsILShift(Protocol[_T_contra, _U_co]):
def __ilshift__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIMod(Protocol[_T_contra, _U_co]):
def __imod__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIMul(Protocol[_T_contra, _U_co]):
def __imul__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIMatMul(Protocol[_T_contra, _U_co]):
def __imatmul__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIOr(Protocol[_T_contra, _U_co]):
def __ior__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIPow(Protocol[_T_contra, _U_co]):
def __ipow__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIRShift(Protocol[_T_contra, _U_co]):
def __irshift__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsISub(Protocol[_T_contra, _U_co]):
def __isub__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsITrueDiv(Protocol[_T_contra, _U_co]):
def __itruediv__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
@type_check_only
class _SupportsIXor(Protocol[_T_contra, _U_co]):
def __ixor__(self, other: _T_contra, /) -> _U_co: ... # noqa: Y034
# All four comparison functions must have the same signature, or we get false-positive errors
def lt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def le(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def ge(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def gt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def eq(a: object, b: object, /) -> Any: ...
def ne(a: object, b: object, /) -> Any: ...
def not_(a: object, /) -> bool: ...
def truth(a: object, /) -> bool: ...
def is_(a: object, b: object, /) -> bool: ...
def is_not(a: object, b: object, /) -> bool: ...
def abs(a: SupportsAbs[_T], /) -> _T: ...
@overload
def add(a: _SupportsAdd[_T, _U], b: _T, /) -> _U: ...
@overload
def add(a: _T, b: _SupportsRAdd[_T, _U], /) -> _U: ...
@overload
def and_(a: _SupportsAnd[_T, _U], b: _T, /) -> _U: ...
@overload
def and_(a: _T, b: _SupportsRAnd[_T, _U], /) -> _U: ...
@overload
def concat(a: _SupportsConcat[_T, _U], b: _T, /) -> _U: ...
@overload
def concat(a: _T, b: _SupportsRConcat[_T, _U], /) -> _U: ...
@overload
def floordiv(a: _SupportsFloorDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def floordiv(a: _T, b: _SupportsRFloorDiv[_T, _U], /) -> _U: ...
def index(a: SupportsIndex, /) -> int: ...
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
@overload
def lshift(a: _SupportsLShift[_T, _U], b: _T, /) -> _U: ...
@overload
def lshift(a: _T, b: _SupportsRLShift[_T, _U], /) -> _U: ...
@overload
def mod(a: _SupportsMod[_T, _U], b: _T, /) -> _U: ...
@overload
def mod(a: _T, b: _SupportsRMod[_T, _U], /) -> _U: ...
@overload
def mul(a: _SupportsMul[_T, _U], b: _T, /) -> _U: ...
@overload
def mul(a: _T, b: _SupportsRMul[_T, _U], /) -> _U: ...
@overload
def matmul(a: _SupportsMatMul[_T, _U], b: _T, /) -> _U: ...
@overload
def matmul(a: _T, b: _SupportsRMatMul[_T, _U], /) -> _U: ...
def neg(a: _SupportsNeg[_T_co], /) -> _T_co: ...
@overload
def or_(a: _SupportsOr[_T, _U], b: _T, /) -> _U: ...
@overload
def or_(a: _T, b: _SupportsROr[_T, _U], /) -> _U: ...
def pos(a: _SupportsPos[_T_co], /) -> _T_co: ...
@overload
def pow(a: _SupportsPow[_T, _U], b: _T, /) -> _U: ...
@overload
def pow(a: _T, b: _SupportsRPow[_T, _U], /) -> _U: ...
@overload
def rshift(a: _SupportsRShift[_T, _U], b: _T, /) -> _U: ...
@overload
def rshift(a: _T, b: _SupportsRRShift[_T, _U], /) -> _U: ...
@overload
def sub(a: _SupportsSub[_T, _U], b: _T, /) -> _U: ...
@overload
def sub(a: _T, b: _SupportsRSub[_T, _U], /) -> _U: ...
@overload
def truediv(a: _SupportsTrueDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def truediv(a: _T, b: _SupportsRTrueDiv[_T, _U], /) -> _U: ...
@overload
def xor(a: _SupportsXor[_T, _U], b: _T, /) -> _U: ...
@overload
def xor(a: _T, b: _SupportsRXor[_T, _U], /) -> _U: ...
def contains(a: _SupportsContains[_T_contra, _U_co], b: _T_contra, /) -> _U_co: ...
def countOf(a: Iterable[object], b: object, /) -> int: ...
@overload
def delitem(a: MutableSequence[Any], b: int, /) -> None: ...
@overload
def delitem(a: MutableSequence[Any], b: slice[int | None], /) -> None: ...
@overload
def delitem(a: MutableMapping[_K, Any], b: _K, /) -> None: ...
@overload
def getitem(a: Sequence[_T], b: slice[int | None], /) -> Sequence[_T]: ...
@overload
def getitem(a: SupportsGetItem[_K, _V], b: _K, /) -> _V: ...
def indexOf(a: Iterable[_T], b: _T, /) -> int: ...
@overload
def setitem(a: MutableSequence[_T], b: int, c: _T, /) -> None: ...
@overload
def setitem(a: MutableSequence[_T], b: slice[int | None], c: Sequence[_T], /) -> None: ...
@overload
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ...
def length_hint(obj: object, default: int = 0, /) -> int: ...
@overload
def iadd(a: _SupportsIAdd[_T, _U], b: _T, /) -> _U: ...
@overload
def iadd(a: _SupportsAdd[_T, _U], b: _T, /) -> _U: ...
@overload
def iadd(a: _T, b: _SupportsRAdd[_T, _U], /) -> _U: ...
@overload
def iand(a: _SupportsIAnd[_T, _U], b: _T, /) -> _U: ...
@overload
def iand(a: _SupportsAnd[_T, _U], b: _T, /) -> _U: ...
@overload
def iand(a: _T, b: _SupportsRAnd[_T, _U], /) -> _U: ...
@overload
def iconcat(a: _SupportsIConcat[_T, _U], b: _T, /) -> _U: ...
@overload
def iconcat(a: _SupportsConcat[_T, _U], b: _T, /) -> _U: ...
@overload
def iconcat(a: _T, b: _SupportsRConcat[_T, _U], /) -> _U: ...
@overload
def ifloordiv(a: _SupportsIFloorDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def ifloordiv(a: _SupportsFloorDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def ifloordiv(a: _T, b: _SupportsRFloorDiv[_T, _U], /) -> _U: ...
@overload
def ilshift(a: _SupportsILShift[_T, _U], b: _T, /) -> _U: ...
@overload
def ilshift(a: _SupportsLShift[_T, _U], b: _T, /) -> _U: ...
@overload
def ilshift(a: _T, b: _SupportsRLShift[_T, _U], /) -> _U: ...
@overload
def imod(a: _SupportsIMod[_T, _U], b: _T, /) -> _U: ...
@overload
def imod(a: _SupportsMod[_T, _U], b: _T, /) -> _U: ...
@overload
def imod(a: _T, b: _SupportsRMod[_T, _U], /) -> _U: ...
@overload
def imul(a: _SupportsIMul[_T, _U], b: _T, /) -> _U: ...
@overload
def imul(a: _SupportsMul[_T, _U], b: _T, /) -> _U: ...
@overload
def imul(a: _T, b: _SupportsRMul[_T, _U], /) -> _U: ...
@overload
def imatmul(a: _SupportsIMatMul[_T, _U], b: _T, /) -> _U: ...
@overload
def imatmul(a: _SupportsMatMul[_T, _U], b: _T, /) -> _U: ...
@overload
def imatmul(a: _T, b: _SupportsRMatMul[_T, _U], /) -> _U: ...
@overload
def ior(a: _SupportsIOr[_T, _U], b: _T, /) -> _U: ...
@overload
def ior(a: _SupportsOr[_T, _U], b: _T, /) -> _U: ...
@overload
def ior(a: _T, b: _SupportsROr[_T, _U], /) -> _U: ...
@overload
def ipow(a: _SupportsIPow[_T, _U], b: _T, /) -> _U: ...
@overload
def ipow(a: _SupportsPow[_T, _U], b: _T, /) -> _U: ...
@overload
def ipow(a: _T, b: _SupportsRPow[_T, _U], /) -> _U: ...
@overload
def irshift(a: _SupportsIRShift[_T, _U], b: _T, /) -> _U: ...
@overload
def irshift(a: _SupportsRShift[_T, _U], b: _T, /) -> _U: ...
@overload
def irshift(a: _T, b: _SupportsRRShift[_T, _U], /) -> _U: ...
@overload
def isub(a: _SupportsISub[_T, _U], b: _T, /) -> _U: ...
@overload
def isub(a: _SupportsSub[_T, _U], b: _T, /) -> _U: ...
@overload
def isub(a: _T, b: _SupportsRSub[_T, _U], /) -> _U: ...
@overload
def itruediv(a: _SupportsITrueDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def itruediv(a: _SupportsTrueDiv[_T, _U], b: _T, /) -> _U: ...
@overload
def itruediv(a: _T, b: _SupportsRTrueDiv[_T, _U], /) -> _U: ...
@overload
def ixor(a: _SupportsIXor[_T, _U], b: _T, /) -> _U: ...
@overload
def ixor(a: _SupportsXor[_T, _U], b: _T, /) -> _U: ...
@overload
def ixor(a: _T, b: _SupportsRXor[_T, _U], /) -> _U: ...
if sys.version_info >= (3, 11):
def call(obj: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
def _compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
if sys.version_info >= (3, 14):
def is_none(a: object, /) -> TypeIs[None]: ...
def is_not_none(a: _T | None, /) -> TypeIs[_T]: ...