Skip to content

Commit

Permalink
Resolve some warnings per python/mypy#12280
Browse files Browse the repository at this point in the history
  • Loading branch information
airallergy committed Mar 20, 2024
1 parent 1197d42 commit 2f77837
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ numpy = "^1.23"
psutil = "^5.9.5"

[tool.poetry.group.dev.dependencies]
mypy = "^1.2.0"
mypy = "^1.9.0"
ruff = "^0.3.0"

[build-system]
Expand Down
10 changes: 5 additions & 5 deletions sober/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class IMapIterator(IMapIterator_):
from multiprocessing.pool import IMapIterator, starmapstar

############################## module typing ##############################
_InitArgs = TypeVarTuple("_InitArgs") # type: ignore[misc] # python/mypy#12280
_InitArgs = TypeVarTuple("_InitArgs")
_P = TypeVar("_P", contravariant=True)
_R = TypeVar("_R", covariant=True)
#############################################################################
Expand All @@ -114,8 +114,8 @@ class _Pool(Pool):
def __init__(
self,
processes: int,
initializer: Callable[[*_InitArgs], None] | None, # type: ignore[valid-type] # python/mypy#12280
initargs: tuple[*_InitArgs], # type: ignore[valid-type] # python/mypy#12280
initializer: Callable[[*_InitArgs], None] | None,
initargs: tuple[*_InitArgs],
) -> None:
super().__init__(
processes, initializer, initargs, context=_MULTIPROCESSING_CONTEXT
Expand Down Expand Up @@ -169,8 +169,8 @@ def _starmap(

def _Parallel( # noqa: N802
n_processes: int,
initializer: Callable[[*_InitArgs], None] | None = None, # type: ignore[valid-type] # python/mypy#12280
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
) -> AnyParallel:
"""a helper function to distribute parallel computation
based on the requested number of processes"""
Expand Down
12 changes: 6 additions & 6 deletions sober/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
AnyDuo: TypeAlias = tuple[_S, _S] # TODO: double check this for float params
AnyIntegralDuo: TypeAlias = AnyDuo[int]
AnyRealDuo: TypeAlias = AnyDuo[float]
AnyDuoVec: TypeAlias = tuple[ # type: ignore[valid-type,misc] # python/mypy#12280
AnyIntegralDuo, *tuple[AnyDuo, ...] # type: ignore[misc] # python/mypy#12280
]
AnyDuoVec: TypeAlias = tuple[AnyIntegralDuo, *tuple[AnyDuo, ...]]

AnyCandidateVec: TypeAlias = tuple[int, *tuple[_S, ...]] # type: ignore[valid-type,misc] # python/mypy#12280
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, ...]]

AnyTask: TypeAlias = tuple[str, AnyDuoVec]
AnyJob: TypeAlias = tuple[str, tuple[AnyTask, ...]]
Expand All @@ -53,7 +51,9 @@

# pymoo
AnyPymooCallback: TypeAlias = pm.Callback | Callable[[pm.Algorithm], None] | None
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


class PymooOut(TypedDict):
Expand Down

0 comments on commit 2f77837

Please sign in to comment.