Files
typeshed/stdlib/_bisect.pyi
Alex Waygood 5670ca2f75 Add SupportsRichComparison type to _typeshed (#6583)
Use it to improve types of `max()` and other functions.

Also make some other tweaks to types related to comparison dunders.

Fixes #6575
2021-12-14 14:12:23 +00:00

36 lines
1.3 KiB
Python

import sys
from _typeshed import SupportsRichComparison
from typing import Callable, MutableSequence, Sequence, TypeVar
_T = TypeVar("_T")
if sys.version_info >= (3, 10):
def bisect_left(
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparison] | None = ...
) -> int: ...
def bisect_right(
a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ..., *, key: Callable[[_T], SupportsRichComparison] | None = ...
) -> int: ...
def insort_left(
a: MutableSequence[_T],
x: _T,
lo: int = ...,
hi: int | None = ...,
*,
key: Callable[[_T], SupportsRichComparison] | None = ...,
) -> None: ...
def insort_right(
a: MutableSequence[_T],
x: _T,
lo: int = ...,
hi: int | None = ...,
*,
key: Callable[[_T], SupportsRichComparison] | None = ...,
) -> None: ...
else:
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> int: ...
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int | None = ...) -> None: ...