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
This commit is contained in:
Alex Waygood
2021-12-14 14:12:23 +00:00
committed by GitHub
parent 968fd6d01d
commit 5670ca2f75
9 changed files with 73 additions and 69 deletions

View File

@@ -1,5 +1,5 @@
import sys
from _typeshed import SupportsLessThanT
from _typeshed import SupportsRichComparisonT
from decimal import Decimal
from fractions import Fraction
from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, Type, TypeVar, Union
@@ -27,8 +27,8 @@ else:
def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ...
def median(data: Iterable[_NumberT]) -> _NumberT: ...
def median_low(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ...
def median_high(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ...
def median_low(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ...
def median_high(data: Iterable[SupportsRichComparisonT]) -> SupportsRichComparisonT: ...
def median_grouped(data: Iterable[_NumberT], interval: _NumberT = ...) -> _NumberT: ...
def mode(data: Iterable[_HashableT]) -> _HashableT: ...