You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That protocol is already defined ad hoc in statistics.pyi, to solve a couple of cases there, but it can also be used in builtins.pyi for max(), min()sorted(), list.sort() or any other function that depends on sorting items to do its job.
For many user-defined functions that use one of these functions internally, a protocol like _Sortable is needed to provide accurate type hints. That's the case of statistics.median_high and median_low: the use cases that prompted the definition of _Sortable in statistics.pyi.
I'm not sure what its name should be. A few options:
Sortable is OK by me.
PEP 484 has an example ABC named Comparable that defines __lt__—but the text suggests the other comparison operators would be part of that ABC.
typing has a bunch of SupportsXyz protocols, so maybe SupportsLessThan?
The text was updated successfully, but these errors were encountered:
ramalho
changed the title
typing should include a single-method protocol for__lt__typing should have a single-method protocol for__lt__May 28, 2020
See also python/typeshed#4131 for a suggestion to add such protocols to typeshed for now and then possibly transferring them to typing if they prove to be used.
On
typeshed
there are several issues that can be fixed with a protocol like this:That protocol is already defined ad hoc in
statistics.pyi
, to solve a couple of cases there, but it can also be used inbuiltins.pyi
formax()
,min()
sorted()
,list.sort()
or any other function that depends on sorting items to do its job.For many user-defined functions that use one of these functions internally, a protocol like
_Sortable
is needed to provide accurate type hints. That's the case ofstatistics.median_high
andmedian_low
: the use cases that prompted the definition of_Sortable
instatistics.pyi
.I'm not sure what its name should be. A few options:
Sortable
is OK by me.Comparable
that defines__lt__
—but the text suggests the other comparison operators would be part of that ABC.typing
has a bunch ofSupportsXyz
protocols, so maybeSupportsLessThan
?The text was updated successfully, but these errors were encountered: