Skip to content

Commit f6c1660

Browse files
authored
Albrja/mic-6086/mypy-cli_options (#266)
Albrja/mic-6086/mypy-cli_options Fix mypy errors in psimulate/cluster/cli_options.py - *Category*: Type-hinting - *JIRA issue*: https://jira.ihme.washington.edu/browse/MIC-6086
1 parent 6f92606 commit f6c1660

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**2.1.14 - 06/16/25**
2+
3+
- Type-hinting: Fix mypy errors in psimulate/cluster/cli_options.py
4+
15
**2.1.13 - 06/11/25**
26

37
- Type-hinting: Fix mypy errors in utilities.py

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ exclude = [
3131
# You will need to remove the mypy: ignore-errors comment from the file heading as well
3232
"docs/source/conf.py",
3333
"setup.py",
34-
"src/vivarium_cluster_tools/psimulate/cluster/cli_options.py",
3534
"src/vivarium_cluster_tools/psimulate/cluster/interface.py",
3635
"src/vivarium_cluster_tools/psimulate/redis_dbs/launcher.py",
3736
"src/vivarium_cluster_tools/psimulate/redis_dbs/registry.py",
@@ -61,5 +60,5 @@ disable_error_code = []
6160

6261
# handle mypy errors when 3rd party packages are not typed.
6362
[[tool.mypy.overrides]]
64-
module = ["drmaa"]
63+
module = ["drmaa", "requests"]
6564
ignore_missing_imports = true

src/vivarium_cluster_tools/psimulate/cluster/cli_options.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: ignore-errors
21
"""
32
===================
43
Cluster CLI options
@@ -7,6 +6,10 @@
76
Command line options for configuring the cluster environment in psimulate runs.
87
98
"""
9+
from __future__ import annotations
10+
11+
from collections.abc import Callable
12+
1013
import click
1114

1215
_RUNTIME_FORMAT = "hh:mm:ss"
@@ -26,8 +29,8 @@
2629

2730

2831
def _validate_and_split_hardware(
29-
ctx: click.Context, param: click.core.Option, value: str | None
30-
) -> list[str | None]:
32+
ctx: click.Context, param: click.Parameter, value: str | None
33+
) -> list[str]:
3134
hardware = value.split(",") if value else []
3235
bad_requests = set(hardware) - set(_AVAILABLE_HARDWARE)
3336
if bad_requests:
@@ -54,7 +57,7 @@ def _validate_and_split_hardware(
5457
)
5558

5659

57-
def with_queue_and_max_runtime(func):
60+
def with_queue_and_max_runtime(func: Callable[..., str]) -> Callable[..., str]:
5861
"""Provide a single decorator for both queue and max runtime
5962
since they are tightly coupled.
6063
@@ -91,7 +94,9 @@ def with_queue_and_max_runtime(func):
9194
)
9295

9396

94-
def _queue_and_runtime_callback(ctx: click.Context, param: str, value: str) -> str:
97+
def _queue_and_runtime_callback(
98+
ctx: click.Context, param: click.Parameter, value: str
99+
) -> str:
95100
if param.name == "queue" and "max_runtime" in ctx.params:
96101
runtime_string, queue = _validate_runtime_and_queue(ctx.params["max_runtime"], value)
97102
ctx.params["max_runtime"], value = runtime_string, queue
@@ -103,7 +108,7 @@ def _queue_and_runtime_callback(ctx: click.Context, param: str, value: str) -> s
103108
return value
104109

105110

106-
def _validate_runtime_and_queue(runtime_string: str, queue: str):
111+
def _validate_runtime_and_queue(runtime_string: str, queue: str | None) -> tuple[str, str]:
107112
try:
108113
hours, minutes, seconds = runtime_string.split(":")
109114
except ValueError:

0 commit comments

Comments
 (0)