8000 stdlib: Add several missing comparison methods (#7202) · python/typeshed@66a229b · GitHub
[go: up one dir, main page]

Skip to content

Commit 66a229b

Browse files
authored
stdlib: Add several missing comparison methods (#7202)
1 parent f3ad017 commit 66a229b

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

stdlib/asyncio/events.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class TimerHandle(Handle):
5555
if sys.version_info >= (3, 7):
5656
def when(self) -> float: ...
5757

58+
def __lt__(self, other: TimerHandle) -> bool: ...
59+
def __le__(self, other: TimerHandle) -> bool: ...
60+
def __gt__(self, other: TimerHandle) -> bool: ...
61+
def __ge__(self, other: TimerHandle) -> bool: ...
62+
5863
class AbstractServer:
5964
@abstractmethod
6065
def close(self) -> None: ...

stdlib/collections/__init__.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ class deque(MutableSequence[_T], Generic[_T]):
220220
def __add__(self: Self, __other: Self) -> Self: ...
221221
def __mul__(self: Self, __other: int) -> Self: ...
222222
def __imul__(self: Self, __other: int) -> Self: ...
223+
def __lt__(self, __other: deque[_T]) -> bool: ...
224+
def __le__(self, __other: deque[_T]) -> bool: ...
225+
def __gt__(self, __other: deque[_T]) -> bool: ...
226+
def __ge__(self, __other: deque[_T]) -> bool: ...
223227
if sys.version_info >= (3, 9):
224228
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
225229

@@ -266,6 +270,10 @@ class Counter(dict[_T, int], Generic[_T]):
266270
def __ior__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[override]
267271
if sys.version_info >= (3, 10):
268272
def total(self) -> int: ...
273+
def __le__(self, other: Counter[object]) -> bool: ...
274+
def __lt__(self, other: Counter[object]) -> bool: ...
275+
def __ge__(self, other: Counter[object]) -> bool: ...
276+
def __gt__(self, other: Counter[object]) -> bool: ...
269277

270278
@final
271279
class _OrderedDictKeysView(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # type: ignore[misc]

stdlib/tracemalloc.pyi

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from _tracemalloc import *
3-
from typing import Optional, Sequence, Union, overload
3+
from typing import Any, Optional, Sequence, Union, overload
44
from typing_extensions import SupportsIndex
55

66
def get_object_traceback(obj: object) -> Traceback | None: ...
@@ -41,6 +41,15 @@ class Frame:
4141
filename: str
4242
lineno: int
4343
def __init__(self, frame: _FrameTupleT) -> None: ...
44+
def __lt__(self, other: Frame) -> bool: ...
45+
if sys.version_info >= (3, 11):
46+
def __gt__(self, other: Frame) -> bool: ...
47+
def __ge__(self, other: Frame) -> bool: ...
48+
def __le__(self, other: Frame) -> bool: ...
49+
else:
50+
def __gt__(self, other: Frame, NotImplemented: Any = ...) -> bool: ...
51+
def __ge__(self, other: Frame, NotImplemented: Any = ...) -> bool: ...
52+
def __le__(self, other: Frame, NotImplemented: Any = ...) -> bool: ...
4453

4554
if sys.version_info >= (3, 9):
4655
_TraceTupleT = Union[tuple[int, int, Sequence[_FrameTupleT], Optional[int]], tuple[int, int, Sequence[_FrameTupleT]]]
@@ -69,6 +78,15 @@ class Traceback(Sequence[Frame]):
6978
@overload
7079
def __getitem__(self, s: slice) -> Sequence[Frame]: ...
7180
def __len__(self) -> int: ...
81+
def __lt__(self, other: Traceback) -> bool: ...
82+
if sys.version_info >= (3, 11):
83+
def __gt__(self, other: Traceback) -> bool: ...
84+
def __ge__(self, other: Traceback) -> bool: ...
85+
def __le__(self, other: Traceback) -> bool: ...
86+
else:
87+
def __gt__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ...
88+
def __ge__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ...
89+
def __le__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ...
7290

7391
class Snapshot:
7492
def __init__(self, traces: Sequence[_TraceTupleT], traceback_limit: int) -> None: ...

stdlib/urllib/request.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class BaseHandler:
9292
parent: OpenerDirector
9393
def add_parent(self, parent: OpenerDirector) -> None: ...
9494
def close(self) -> None: ...
95+
def __lt__(self, other: object) -> bool: ...
9596

9697
class HTTPDefaultErrorHandler(BaseHandler):
9798
def http_error_default(

stdlib/xml/etree/ElementTree.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ PI: Callable[..., Element]
111111
class QName:
112112
text: str
113113
def __init__(self, text_or_uri: str, tag: str | None = ...) -> None: ...
114+
def __lt__(self, other: QName | str) -> bool: ...
115+
def __le__(self, other: QName | str) -> bool: ...
116+
def __gt__(self, other: QName | str) -> bool: ...
117+
def __ge__(self, other: QName | str) -> bool: ...
114118

115119
class ElementTree:
116120
def __init__(self, element: Element | None = ..., file: _File | None = ...) -> None: ...

0 commit comments

Comments
 (0)
0