mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 18:31:14 +08:00
_typeshed: add SupportsLessThan, SupportsLessThanT (#4711)
And use it everywhere. Note there seemed to be a discrepancy between heapq in Python 2 and 3, so I changed that. It should probably be more widely used within heapq, but leaving that out of scope for this PR. Co-authored-by: hauntsaninja <>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from _typeshed import SupportsLessThanT
|
||||
from decimal import Decimal
|
||||
from fractions import Fraction
|
||||
from typing import Any, Hashable, Iterable, List, Optional, Protocol, SupportsFloat, Type, TypeVar, Union
|
||||
@@ -7,12 +8,6 @@ _T = TypeVar("_T")
|
||||
# Most functions in this module accept homogeneous collections of one of these types
|
||||
_Number = TypeVar("_Number", float, Decimal, Fraction)
|
||||
|
||||
# Used in median_high, median_low
|
||||
class _Sortable(Protocol):
|
||||
def __lt__(self, other: Any) -> bool: ...
|
||||
|
||||
_SortableT = TypeVar("_SortableT", bound=_Sortable)
|
||||
|
||||
# Used in mode, multimode
|
||||
_HashableT = TypeVar("_HashableT", bound=Hashable)
|
||||
|
||||
@@ -28,8 +23,8 @@ if sys.version_info >= (3, 6):
|
||||
def harmonic_mean(data: Iterable[_Number]) -> _Number: ...
|
||||
|
||||
def median(data: Iterable[_Number]) -> _Number: ...
|
||||
def median_low(data: Iterable[_SortableT]) -> _SortableT: ...
|
||||
def median_high(data: Iterable[_SortableT]) -> _SortableT: ...
|
||||
def median_low(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ...
|
||||
def median_high(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ...
|
||||
def median_grouped(data: Iterable[_Number], interval: _Number = ...) -> _Number: ...
|
||||
def mode(data: Iterable[_HashableT]) -> _HashableT: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user