|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from copy import copy |
4 | | -from typing import Any, Tuple |
| 4 | +from typing import Any, Callable, Iterable, Tuple |
5 | 5 |
|
6 | 6 | import cloudpickle |
7 | 7 | from sortedcontainers import SortedDict, SortedSet |
@@ -37,17 +37,17 @@ class _IgnoreFirstArgument: |
37 | 37 | pickable. |
38 | 38 | """ |
39 | 39 |
|
40 | | - def __init__(self, function): |
41 | | - self.function = function |
| 40 | + def __init__(self, function: Callable) -> None: |
| 41 | + self.function = function # type: ignore |
42 | 42 |
|
43 | 43 | def __call__(self, index_point: PointType, *args, **kwargs): |
44 | 44 | index, point = index_point |
45 | 45 | return self.function(point, *args, **kwargs) |
46 | 46 |
|
47 | | - def __getstate__(self): |
| 47 | + def __getstate__(self) -> Callable: |
48 | 48 | return self.function |
49 | 49 |
|
50 | | - def __setstate__(self, function): |
| 50 | + def __setstate__(self, function: Callable) -> None: |
51 | 51 | self.__init__(function) |
52 | 52 |
|
53 | 53 |
|
@@ -78,9 +78,9 @@ class SequenceLearner(BaseLearner): |
78 | 78 | the added benefit of having results in the local kernel already. |
79 | 79 | """ |
80 | 80 |
|
81 | | - def __init__(self, function, sequence): |
| 81 | + def __init__(self, function: Callable, sequence: Iterable) -> None: |
82 | 82 | self._original_function = function |
83 | | - self.function = _IgnoreFirstArgument(function) |
| 83 | + self.function = _IgnoreFirstArgument(function) # type: ignore |
84 | 84 | self._to_do_indices = SortedSet({i for i, _ in enumerate(sequence)}) |
85 | 85 | self._ntotal = len(sequence) |
86 | 86 | self.sequence = copy(sequence) |
|
0 commit comments