Skip to content

Commit f06f061

Browse files
committed
mypy 1.11.x type fixes, the callback is not optional
1 parent 8185991 commit f06f061

9 files changed

+19
-19
lines changed

cwltool/command_line_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def remove_dirname(d: CWLObjectType) -> None:
806806
def job(
807807
self,
808808
job_order: CWLObjectType,
809-
output_callbacks: Optional[OutputCallbackType],
809+
output_callbacks: OutputCallbackType,
810810
runtimeContext: RuntimeContext,
811811
) -> Generator[Union[JobBase, CallbackJob], None, None]:
812812
workReuse, _ = self.get_requirement("WorkReuse")

cwltool/process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ def visit(self, op: Callable[[CommentedMap], None]) -> None:
10751075
def job(
10761076
self,
10771077
job_order: CWLObjectType,
1078-
output_callbacks: Optional[OutputCallbackType],
1078+
output_callbacks: OutputCallbackType,
10791079
runtimeContext: RuntimeContext,
10801080
) -> JobsGeneratorType:
10811081
pass

cwltool/procgenerator.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def receive_output(self, jobout: Optional[CWLObjectType], processStatus: str) ->
3030
def job(
3131
self,
3232
job_order: CWLObjectType,
33-
output_callbacks: Optional[OutputCallbackType],
33+
output_callbacks: OutputCallbackType,
3434
runtimeContext: RuntimeContext,
3535
) -> JobsGeneratorType:
3636
try:
@@ -41,7 +41,7 @@ def job(
4141
while self.processStatus is None:
4242
yield None
4343

44-
if self.processStatus != "success" and output_callbacks:
44+
if self.processStatus != "success":
4545
output_callbacks(self.jobout, self.processStatus)
4646
return
4747

@@ -89,7 +89,7 @@ def __init__(
8989
def job(
9090
self,
9191
job_order: CWLObjectType,
92-
output_callbacks: Optional[OutputCallbackType],
92+
output_callbacks: OutputCallbackType,
9393
runtimeContext: RuntimeContext,
9494
) -> JobsGeneratorType:
9595
return ProcessGeneratorJob(self).job(job_order, output_callbacks, runtimeContext)

cwltool/workflow.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def make_workflow_step(
153153
def job(
154154
self,
155155
job_order: CWLObjectType,
156-
output_callbacks: Optional[OutputCallbackType],
156+
output_callbacks: OutputCallbackType,
157157
runtimeContext: RuntimeContext,
158158
) -> JobsGeneratorType:
159159
builder = self._init_job(job_order, runtimeContext)
@@ -420,7 +420,7 @@ def receive_output(
420420
def job(
421421
self,
422422
job_order: CWLObjectType,
423-
output_callbacks: Optional[OutputCallbackType],
423+
output_callbacks: OutputCallbackType,
424424
runtimeContext: RuntimeContext,
425425
) -> JobsGeneratorType:
426426
"""Initialize sub-workflow as a step in the parent profile."""

cwltool/workflow_job.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, step: "WorkflowStep") -> None:
6565
def job(
6666
self,
6767
joborder: CWLObjectType,
68-
output_callback: Optional[OutputCallbackType],
68+
output_callback: OutputCallbackType,
6969
runtimeContext: RuntimeContext,
7070
) -> JobsGeneratorType:
7171
runtimeContext = runtimeContext.copy()
@@ -584,7 +584,7 @@ def receive_output(
584584
def try_make_job(
585585
self,
586586
step: WorkflowJobStep,
587-
final_output_callback: Optional[OutputCallbackType],
587+
final_output_callback: OutputCallbackType,
588588
runtimeContext: RuntimeContext,
589589
) -> JobsGeneratorType:
590590
container_engine = "docker"
@@ -773,7 +773,7 @@ def run(
773773
def job(
774774
self,
775775
joborder: CWLObjectType,
776-
output_callback: Optional[OutputCallbackType],
776+
output_callback: OutputCallbackType,
777777
runtimeContext: RuntimeContext,
778778
) -> JobsGeneratorType:
779779
self.state = {}
@@ -848,7 +848,7 @@ def job(
848848
else:
849849
yield None
850850

851-
if not self.did_callback and output_callback:
851+
if not self.did_callback:
852852
# could have called earlier on line 336;
853853
self.do_output_callback(output_callback)
854854
# depends which one comes first. All steps are completed

tests/test_context.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_replace_default_stdout_stderr() -> None:
1414
original_stdout = sys.stdout
1515
original_stderr = sys.stderr
1616

17-
sys.stdout = "" # type: ignore
18-
sys.stderr = "" # type: ignore
17+
sys.stdout = ""
18+
sys.stderr = ""
1919

2020
runtime_context = RuntimeContext()
2121
runtime_context.default_stdout = subprocess.DEVNULL # type: ignore

tests/test_load_tool.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def test_check_version() -> None:
3030
joborder: CWLObjectType = {"inp": "abc"}
3131
loadingContext = LoadingContext({"do_update": True})
3232
tool = load_tool(get_data("tests/echo.cwl"), loadingContext)
33-
for _ in tool.job(joborder, None, RuntimeContext()):
33+
for _ in tool.job(joborder, lambda output, process_status: None, RuntimeContext()):
3434
pass
3535

3636
loadingContext = LoadingContext({"do_update": False})
3737
tool = load_tool(get_data("tests/echo.cwl"), loadingContext)
3838
with pytest.raises(WorkflowException):
39-
for _ in tool.job(joborder, None, RuntimeContext()):
39+
for _ in tool.job(joborder, lambda output, process_status: None, RuntimeContext()):
4040
pass
4141

4242

tests/test_streaming.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_regular_file() -> None:
6161
}
6262
}
6363

64-
job = next(clt.job(joborder, None, runtime_context))
64+
job = next(clt.job(joborder, lambda output, process_status: None, runtime_context))
6565
assert isinstance(job, JobBase)
6666

6767
job._setup(runtime_context)
@@ -99,7 +99,7 @@ def test_input_can_be_named_pipe(
9999
}
100100
}
101101

102-
job = next(clt.job(joborder, None, runtime_context))
102+
job = next(clt.job(joborder, lambda output, process_status: None, runtime_context))
103103
assert isinstance(job, JobBase)
104104

105105
if raise_exception:

tests/test_tmpdir.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_docker_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None:
6666
"tmp_outdir_prefix": tmp_outdir_prefix,
6767
}
6868
)
69-
job = next(clt.job({}, None, runtime_context))
69+
job = next(clt.job({}, lambda output, process_status: None, runtime_context))
7070
assert isinstance(job, JobBase)
7171
assert job.stagedir and job.stagedir.startswith(tmpdir_prefix)
7272
assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix)
@@ -106,7 +106,7 @@ def test_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None:
106106
"tmp_outdir_prefix": tmp_outdir_prefix,
107107
}
108108
)
109-
job = next(clt.job({}, None, runtime_context))
109+
job = next(clt.job({}, lambda output, process_status: None, runtime_context))
110110
assert isinstance(job, JobBase)
111111
assert job.stagedir and job.stagedir.startswith(tmpdir_prefix)
112112
assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix)

0 commit comments

Comments
 (0)