Skip to content

Commit b17f0fc

Browse files
committed
[_operator] Type add and sub mimicking mul in #15598.
1 parent 4567c8c commit b17f0fc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/_operator.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import SupportsGetItem, SupportsMul, SupportsRMul
2+
from _typeshed import SupportsAdd, SupportsGetItem, SupportsMul, SupportsRAdd, SupportsRMul, SupportsRSub, SupportsSub
33
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
44
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
55
from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only
@@ -59,7 +59,10 @@ def truth(a: object, /) -> bool: ...
5959
def is_(a: object, b: object, /) -> bool: ...
6060
def is_not(a: object, b: object, /) -> bool: ...
6161
def abs(a: SupportsAbs[_T], /) -> _T: ...
62-
def add(a, b, /): ...
62+
@overload
63+
def add(a: SupportsAdd[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
64+
@overload
65+
def add(a: _T_contra, b: SupportsRAdd[_T_contra, _T_co], /) -> _T_co: ...
6366
def and_(a, b, /): ...
6467
def floordiv(a, b, /): ...
6568
def index(a: SupportsIndex, /) -> int: ...
@@ -77,7 +80,10 @@ def or_(a, b, /): ...
7780
def pos(a: _SupportsPos[_T_co], /) -> _T_co: ...
7881
def pow(a, b, /): ...
7982
def rshift(a, b, /): ...
80-
def sub(a, b, /): ...
83+
@overload
84+
def sub(a: SupportsSub[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
85+
@overload
86+
def sub(a: _T_contra, b: SupportsRSub[_T_contra, _T_co], /) -> _T_co: ...
8187
def truediv(a, b, /): ...
8288
def xor(a, b, /): ...
8389
def concat(a: Sequence[_T], b: Sequence[_T], /) -> Sequence[_T]: ...

0 commit comments

Comments
 (0)