Skip to content

Commit a0a9dc3

Browse files
committed
fix: mypy
1 parent 01b9a42 commit a0a9dc3

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

cwltool/checker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,14 @@ def loop_checker(steps: Iterator[MutableMapping[str, Any]]) -> None:
559559
raise ValidationException("\n".join(exceptions))
560560

561561

562-
def resreq_minmax_checker(requirement: CWLObjectType):
562+
def resreq_minmax_checker(requirement: CWLObjectType) -> None:
563563
"""
564564
Check if the minResource is lesser than the maxResource in resource requirements.
565565
566566
:raises ValidationException: If the minResource is greater than the maxResource.
567567
"""
568568
for a in ("cores", "ram", "tmpdir", "outdir"):
569-
mn: int | float | None = requirement.get(a + "Min")
570-
mx: int | float | None = requirement.get(a + "Max")
569+
mn: int | float | None = cast(Union[int, float], requirement.get(a + "Min"))
570+
mx: int | float | None = cast(Union[int, float], requirement.get(a + "Max"))
571571
if mn is not None and mx is not None and mx < mn:
572572
raise ValidationException(f"{a}Min cannot be greater than {a}Max.")

cwltool/process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,11 @@ def evalResources(
10271027
elif mx is None:
10281028
mx = mn
10291029

1030-
if mn is not None:
1030+
if mn is not None and mx is not None:
10311031
if mx < mn:
10321032
raise ValidationException(f"{a}Min cannot be greater than {a}Max.")
10331033
request[a + "Min"] = mn
1034-
request[a + "Max"] = cast(Union[int, float], mx)
1034+
request[a + "Max"] = mx
10351035

10361036
request_evaluated = cast(dict[str, Union[int, float]], request)
10371037
if runtimeContext.select_resources is not None:

tests/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,7 @@ def test_make_template() -> None:
18461846
@pytest.mark.parametrize(
18471847
"file", ["tests/wf/bad_resreq_mnmx_clt.cwl", "tests/wf/bad_resreq_mnmx_wf.cwl"]
18481848
)
1849-
def test_invalid_resource_requirements(file):
1849+
def test_invalid_resource_requirements(file: str) -> None:
18501850
"""Ensure an error with an invalid resource requirement."""
18511851
exit_code, stdout, stderr = get_main_output(
18521852
[

tests/test_validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io
44
import logging
55
import re
6+
67
import pytest
78

89
from .util import get_data, get_main_output
@@ -131,7 +132,7 @@ def test_validate_custom_logger() -> None:
131132
@pytest.mark.parametrize(
132133
"file", ["tests/wf/bad_resreq_mnmx_clt.cwl", "tests/wf/bad_resreq_mnmx_wf.cwl"]
133134
)
134-
def test_validate_with_invalid_requirements(file) -> None:
135+
def test_validate_with_invalid_requirements(file: str) -> None:
135136
"""Ensure that --validate returns an error with an invalid resource requirement."""
136137
exit_code, stdout, stderr = get_main_output(
137138
[

0 commit comments

Comments
 (0)