8000
We read every piece of feedback, and take your input very seriously.
1 parent 1197d42 commit 2f77837Copy full SHA for 2f77837
pyproject.toml
@@ -14,7 +14,7 @@ numpy = "^1.23"
14
psutil = "^5.9.5"
15
16
[tool.poetry.group.dev.dependencies]
17
-mypy = "^1.2.0"
+mypy = "^1.9.0"
18
ruff = "^0.3.0"
19
20
[build-system]
sober/_tools.py
@@ -92,7 +92,7 @@ class IMapIterator(IMapIterator_):
92
from multiprocessing.pool import IMapIterator, starmapstar
93
94
############################## module typing ##############################
95
-_InitArgs = TypeVarTuple("_InitArgs") # type: ignore[misc] # python/mypy#12280
+_InitArgs = TypeVarTuple("_InitArgs")
96
_P = TypeVar("_P", contravariant=True)
97
_R = TypeVar("_R", covariant=True)
98
#############################################################################
@@ -114,8 +114,8 @@ class _Pool(Pool):
114
def __init__(
115
self,
116
processes: int,
117
- initializer: Callable[[*_InitArgs], None] | None, # type: ignore[valid-type] # python/mypy#12280
118
- initargs: tuple[*_InitArgs], # type: ignore[valid-type] # python/mypy#12280
+ initializer: Callable[[*_InitArgs], None] | None,
+ initargs: tuple[*_InitArgs],
119
) -> None:
120
super().__init__(
121
processes, initializer, initargs, context=_MULTIPROCESSING_CONTEXT
@@ -169,8 +169,8 @@ def _starmap(
169
170
def _Parallel( # noqa: N802
171
n_processes: int,
172
- initializer: Callable[[*_InitArgs], None] | None = None, # type: ignore[valid-type] # python/mypy#12280
173
- initargs: tuple[*_InitArgs] = (), # type: ignore[valid-type,assignment] # python/mypy#12280
+ initializer: Callable[[*_InitArgs], None] | None = None,
+ initargs: tuple[*_InitArgs] = (), # type:ignore[assignment] # TODO: wait to see the multiprocessing typeshed
174
) -> AnyParallel:
175
"""a helper function to distribute parallel computation
176
based on the requested number of processes"""
sober/_typing.py
@@ -35,12 +35,10 @@
35
AnyDuo: TypeAlias = tuple[_S, _S] # TODO: double check this for float params
36
AnyIntegralDuo: TypeAlias = AnyDuo[int]
37
AnyRealDuo: TypeAlias = AnyDuo[float]
38
-AnyDuoVec: TypeAlias = tuple[ # type: ignore[valid-type,misc] # python/mypy#12280
39
- AnyIntegralDuo, *tuple[AnyDuo, ...] # type: ignore[misc] # python/mypy#12280
40
-]
+AnyDuoVec: TypeAlias = tuple[AnyIntegralDuo, *tuple[AnyDuo, ...]]
41
42
-AnyCandidateVec: TypeAlias = tuple[int, *tuple[_S, ...]] # type: ignore[valid-type,misc] # python/mypy#12280
43
-AnyScenarioVec: TypeAlias = tuple[int, *tuple[_S, ...]] # type: ignore[valid-type,misc] # python/mypy#12280
+AnyCandidateVec: TypeAlias = tuple[int, *tuple[_S, ...]]
+AnyScenarioVec: TypeAlias = tuple[int, *tuple[_S, ...]]
44
45
AnyTask: TypeAlias = tuple[str, AnyDuoVec]
46
AnyJob: TypeAlias = tuple[str, tuple[AnyTask, ...]]
@@ -53,7 +51,9 @@
53
51
54
52
# pymoo
55
AnyPymooCallback: TypeAlias = pm.Callback | Callable[[pm.Algorithm], None] | None
56
-AnyCandidateMap: TypeAlias = dict[str, np.integer | np.floating]
+AnyCandidateMap: TypeAlias = dict[
+ str, np.integer | np.floating
+] # TODO: find a way to type the first element as int
57
58
59
class PymooOut(TypedDict):