11
11
)
12
12
import collections
13
13
import types
14
+ from collections .abc import Callable
14
15
15
16
from functional .execution import ExecutionStrategies
16
17
24
25
CACHE_T = Transformation ("cache" , None , None )
25
26
26
27
27
- def name (function ):
28
+ def name (function : Callable ):
28
29
"""
29
30
Retrieve a pretty name for the function
30
31
:param function: function to get name from
@@ -36,7 +37,7 @@ def name(function):
36
37
return str (function )
37
38
38
39
39
- def map_t (func ):
40
+ def map_t (func : Callable ):
40
41
"""
41
42
Transformation for Sequence.map
42
43
:param func: map function
@@ -49,7 +50,7 @@ def map_t(func):
49
50
)
50
51
51
52
52
- def select_t (func ):
53
+ def select_t (func : Callable ):
53
54
"""
54
55
Transformation for Sequence.select
55
56
:param func: select function
@@ -62,7 +63,7 @@ def select_t(func):
62
63
)
63
64
64
65
65
- def starmap_t (func ):
66
+ def starmap_t (func : Callable ):
66
67
"""
67
68
Transformation for Sequence.starmap and Sequence.smap
68
69
:param func: starmap function
@@ -75,7 +76,7 @@ def starmap_t(func):
75
76
)
76
77
77
78
78
- def filter_t (func ):
79
+ def filter_t (func : Callable ):
79
80
"""
80
81
Transformation for Sequence.filter
81
82
:param func: filter function
@@ -88,7 +89,7 @@ def filter_t(func):
88
89
)
89
90
90
91
91
- def where_t (func ):
92
+ def where_t (func : Callable ):
92
93
"""
93
94
Transformation for Sequence.where
94
95
:param func: where function
@@ -101,7 +102,7 @@ def where_t(func):
101
102
)
102
103
103
104
104
- def filter_not_t (func ):
105
+ def filter_not_t (func : Callable ):
105
106
"""
106
107
Transformation for Sequence.filter_not
107
108
:param func: filter_not function
@@ -122,7 +123,7 @@ def reversed_t():
122
123
return Transformation ("reversed" , reversed , [ExecutionStrategies .PRE_COMPUTE ])
123
124
124
125
125
- def slice_t (start , until ):
126
+ def slice_t (start : int , until : int ):
126
127
"""
127
128
Transformation for Sequence.slice
128
129
:param start: start index
@@ -153,7 +154,7 @@ def distinct(sequence):
153
154
return Transformation ("distinct" , distinct , None )
154
155
155
156
156
- def distinct_by_t (func ):
157
+ def distinct_by_t (func : Callable ):
157
158
"""
158
159
Transformation for Sequence.distinct_by
159
160
:param func: distinct_by function
@@ -171,7 +172,7 @@ def distinct_by(sequence):
171
172
return Transformation ("distinct_by({0})" .format (name (func )), distinct_by , None )
172
173
173
174
174
- def sorted_t (key = None , reverse = False ):
175
+ def sorted_t (key = None , reverse : bool = False ):
175
176
"""
176
177
Transformation for Sequence.sorted
177
178
:param key: key to sort by
@@ -183,7 +184,7 @@ def sorted_t(key=None, reverse=False):
183
184
)
184
185
185
186
186
- def order_by_t (func ):
187
+ def order_by_t (func : Callable ):
187
188
"""
188
189
Transformation for Sequence.order_by
189
190
:param func: order_by function
@@ -196,7 +197,7 @@ def order_by_t(func):
196
197
)
197
198
198
199
199
- def drop_right_t (n ):
200
+ def drop_right_t (n : int ):
200
201
"""
201
202
Transformation for Sequence.drop_right
202
203
:param n: number to drop from right
@@ -213,7 +214,7 @@ def drop_right_t(n):
213
214
)
214
215
215
216
216
- def drop_t (n ):
217
+ def drop_t (n : int ):
217
218
"""
218
219
Transformation for Sequence.drop
219
220
:param n: number to drop from left
@@ -224,7 +225,7 @@ def drop_t(n):
224
225
)
225
226
226
227
227
- def drop_while_t (func ):
228
+ def drop_while_t (func : Callable ):
228
229
"""
229
230
Transformation for Sequence.drop_while
230
231
:param func: drops while func is true
@@ -235,7 +236,7 @@ def drop_while_t(func):
235
236
)
236
237
237
238
238
- def take_t (n ):
239
+ def take_t (n : int ):
239
240
"""
240
241
Transformation for Sequence.take
241
242
:param n: number to take
@@ -246,7 +247,7 @@ def take_t(n):
246
247
)
247
248
248
249
249
- def take_while_t (func ):
250
+ def take_while_t (func : Callable ):
250
251
"""
251
252
Transformation for Sequence.take_while
252
253
:param func: takes while func is True
@@ -257,7 +258,7 @@ def take_while_t(func):
257
258
)
258
259
259
260
260
- def flat_map_impl (func , sequence ):
261
+ def flat_map_impl (func : Callable , sequence ):
261
262
"""
262
263
Implementation for flat_map_t
263
264
:param func: function to map
@@ -720,7 +721,7 @@ def peek_impl(func, sequence):
720
721
yield element
721
722
722
723
723
- def peek_t (func ):
724
+ def peek_t (func : Callable ):
724
725
"""
725
726
Transformation for Sequence.peek
726
727
:param func: peek function
0 commit comments