37
37
overload ,
38
38
)
39
39
40
- from expression .core import Case , Nothing , Option , Some , pipe
40
+ from expression .core import Case , Nothing , Option , Some , SupportsLessThan , pipe
41
41
42
42
from . import seq
43
43
44
44
TSource = TypeVar ("TSource" )
45
+ TSourceSortable = TypeVar ("TSourceSortable" , bound = SupportsLessThan )
45
46
TSourceIn = TypeVar ("TSourceIn" , contravariant = True )
46
47
TResult = TypeVar ("TResult" )
47
48
TResultOut = TypeVar ("TResultOut" , covariant = True )
48
49
TState = TypeVar ("TState" )
50
+
49
51
T1 = TypeVar ("T1" )
50
52
T2 = TypeVar ("T2" )
51
53
T3 = TypeVar ("T3" )
@@ -356,7 +358,7 @@ def tail(self) -> FrozenList[TSource]:
356
358
_ , * tail = self .value
357
359
return FrozenList (tail )
358
360
359
- def sort (self , reverse : bool = False ) -> FrozenList [TSource ]:
361
+ def sort (self : FrozenList [ TSourceSortable ] , reverse : bool = False ) -> FrozenList [TSourceSortable ]:
360
362
"""Sort list directly.
361
363
362
364
Returns a new sorted collection.
@@ -779,7 +781,7 @@ def _skip_last(source: FrozenList[TSource]) -> FrozenList[TSource]:
779
781
return _skip_last
780
782
781
783
782
- def sort (reverse = False ) -> Callable [[FrozenList [TSource ]], FrozenList [TSource ]]:
784
+ def sort (reverse : bool = False ) -> Callable [[FrozenList [TSourceSortable ]], FrozenList [TSourceSortable ]]:
783
785
"""Returns a new sorted collection
784
786
785
787
Args:
@@ -789,7 +791,7 @@ def sort(reverse=False) -> Callable[[FrozenList[TSource]], FrozenList[TSource]]:
789
791
Partially applied sort function.
790
792
"""
791
793
792
- def _sort (source : FrozenList [TSource ]) -> FrozenList [TSource ]:
794
+ def _sort (source : FrozenList [TSourceSortable ]) -> FrozenList [TSourceSortable ]:
793
795
"""Returns a new sorted collection
794
796
795
797
Args:
@@ -803,7 +805,9 @@ def _sort(source: FrozenList[TSource]) -> FrozenList[TSource]:
803
805
return _sort
804
806
805
807
806
- def sort_with (func : Callable [[TSource ], Any ], reverse = False ) -> Callable [[FrozenList [TSource ]], FrozenList [TSource ]]:
808
+ def sort_with (
809
+ func : Callable [[TSource ], Any ], reverse : bool = False
810
+ ) -> Callable [[FrozenList [TSource ]], FrozenList [TSource ]]:
807
811
"""Returns a new collection sorted using "func" key function.
808
812
809
813
Args:
0 commit comments