Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions stdlib/_operator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ 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")
Expand Down Expand Up @@ -58,15 +61,45 @@ 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: ...
def add(a: Any, b: Any, /) -> Any: ...
def and_(a: Any, b: Any, /) -> Any: ...

class _SupportsAdd(Protocol[_T_contra, _U_co]):
def __add__(self, other: _T_contra, /) -> _U_co: ...

class _SupportsRAdd(Protocol[_T_contra, _U_co]):
def __radd__(self, other: _T_contra, /) -> _U_co: ...

@overload
def add(a: _SupportsAdd[_T, _U], b: _T, /) -> _U: ...
@overload
def add(a: _T, b: _SupportsRAdd[_T, _U], /) -> _U: ...

class _SupportsAnd(Protocol[_T_contra, _U_co]):
def __and__(self, other: _T_contra, /) -> _U_co: ...

class _SupportsRAnd(Protocol[_T_contra, _U_co]):
def __rand__(self, other: _T_contra, /) -> _U_co: ...

@overload
def and_(a: _SupportsAnd[_T, _U], b: _T, /) -> _U: ...
@overload
def and_(a: _T, b: _SupportsRAnd[_T, _U], /) -> _U: ...
def floordiv(a: Any, b: Any, /) -> Any: ...
def index(a: SupportsIndex, /) -> int: ...
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def lshift(a: Any, b: Any, /) -> Any: ...
def mod(a: Any, b: Any, /) -> Any: ...
def mul(a: Any, b: Any, /) -> Any: ...

class _SupportsMul(Protocol[_T_contra, _U_co]):
def __mul__(self, other: _T_contra, /) -> _U_co: ...

class _SupportsRMul(Protocol[_T_contra, _U_co]):
def __rmul__(self, other: _T_contra, /) -> _U_co: ...

@overload
def mul(a: _SupportsMul[_T, _U], b: _T, /) -> _U: ...
@overload
def mul(a: _T, b: _SupportsRMul[_T, _U], /) -> _U: ...
def matmul(a: Any, b: Any, /) -> Any: ...
def neg(a: _SupportsNeg[_T_co], /) -> _T_co: ...
def or_(a: Any, b: Any, /) -> Any: ...
Expand Down