diff --git a/cwltool/command_line_tool.py b/cwltool/command_line_tool.py index b11bb4bc3..7a4e8ff71 100644 --- a/cwltool/command_line_tool.py +++ b/cwltool/command_line_tool.py @@ -806,7 +806,7 @@ def remove_dirname(d: CWLObjectType) -> None: def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> Generator[Union[JobBase, CallbackJob], None, None]: workReuse, _ = self.get_requirement("WorkReuse") diff --git a/cwltool/process.py b/cwltool/process.py index afbed8147..bde035118 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -1075,7 +1075,7 @@ def visit(self, op: Callable[[CommentedMap], None]) -> None: def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: pass diff --git a/cwltool/procgenerator.py b/cwltool/procgenerator.py index 0f1801b2d..34c1e650f 100644 --- a/cwltool/procgenerator.py +++ b/cwltool/procgenerator.py @@ -30,7 +30,7 @@ def receive_output(self, jobout: Optional[CWLObjectType], processStatus: str) -> def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: try: @@ -41,7 +41,7 @@ def job( while self.processStatus is None: yield None - if self.processStatus != "success" and output_callbacks: + if self.processStatus != "success": output_callbacks(self.jobout, self.processStatus) return @@ -89,7 +89,7 @@ def __init__( def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: return ProcessGeneratorJob(self).job(job_order, output_callbacks, runtimeContext) diff --git a/cwltool/workflow.py b/cwltool/workflow.py index 727331dd4..982ec7e70 100644 --- a/cwltool/workflow.py +++ b/cwltool/workflow.py @@ -153,7 +153,7 @@ def make_workflow_step( def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: builder = self._init_job(job_order, runtimeContext) @@ -420,7 +420,7 @@ def receive_output( def job( self, job_order: CWLObjectType, - output_callbacks: Optional[OutputCallbackType], + output_callbacks: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: """Initialize sub-workflow as a step in the parent profile.""" diff --git a/cwltool/workflow_job.py b/cwltool/workflow_job.py index e6c1f8d8a..8402b2b4b 100644 --- a/cwltool/workflow_job.py +++ b/cwltool/workflow_job.py @@ -65,7 +65,7 @@ def __init__(self, step: "WorkflowStep") -> None: def job( self, joborder: CWLObjectType, - output_callback: Optional[OutputCallbackType], + output_callback: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: runtimeContext = runtimeContext.copy() @@ -584,7 +584,7 @@ def receive_output( def try_make_job( self, step: WorkflowJobStep, - final_output_callback: Optional[OutputCallbackType], + final_output_callback: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: container_engine = "docker" @@ -773,7 +773,7 @@ def run( def job( self, joborder: CWLObjectType, - output_callback: Optional[OutputCallbackType], + output_callback: OutputCallbackType, runtimeContext: RuntimeContext, ) -> JobsGeneratorType: self.state = {} @@ -848,7 +848,7 @@ def job( else: yield None - if not self.did_callback and output_callback: + if not self.did_callback: # could have called earlier on line 336; self.do_output_callback(output_callback) # depends which one comes first. All steps are completed diff --git a/mypy-requirements.txt b/mypy-requirements.txt index 31c4c0211..628a75488 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -1,4 +1,4 @@ -mypy==1.10.1 # also update pyproject.toml +mypy==1.11.1 # also update pyproject.toml ruamel.yaml>=0.16.0,<0.19 cwl-utils>=0.32 types-requests diff --git a/tests/test_context.py b/tests/test_context.py index 754216048..acb7dfbca 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -14,8 +14,8 @@ def test_replace_default_stdout_stderr() -> None: original_stdout = sys.stdout original_stderr = sys.stderr - sys.stdout = "" # type: ignore - sys.stderr = "" # type: ignore + sys.stdout = "" + sys.stderr = "" runtime_context = RuntimeContext() runtime_context.default_stdout = subprocess.DEVNULL # type: ignore diff --git a/tests/test_load_tool.py b/tests/test_load_tool.py index 2c504eafd..2b9e9b6ed 100644 --- a/tests/test_load_tool.py +++ b/tests/test_load_tool.py @@ -30,13 +30,13 @@ def test_check_version() -> None: joborder: CWLObjectType = {"inp": "abc"} loadingContext = LoadingContext({"do_update": True}) tool = load_tool(get_data("tests/echo.cwl"), loadingContext) - for _ in tool.job(joborder, None, RuntimeContext()): + for _ in tool.job(joborder, lambda output, process_status: None, RuntimeContext()): pass loadingContext = LoadingContext({"do_update": False}) tool = load_tool(get_data("tests/echo.cwl"), loadingContext) with pytest.raises(WorkflowException): - for _ in tool.job(joborder, None, RuntimeContext()): + for _ in tool.job(joborder, lambda output, process_status: None, RuntimeContext()): pass diff --git a/tests/test_streaming.py b/tests/test_streaming.py index 83ad81e0d..aef4a7efe 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -61,7 +61,7 @@ def test_regular_file() -> None: } } - job = next(clt.job(joborder, None, runtime_context)) + job = next(clt.job(joborder, lambda output, process_status: None, runtime_context)) assert isinstance(job, JobBase) job._setup(runtime_context) @@ -99,7 +99,7 @@ def test_input_can_be_named_pipe( } } - job = next(clt.job(joborder, None, runtime_context)) + job = next(clt.job(joborder, lambda output, process_status: None, runtime_context)) assert isinstance(job, JobBase) if raise_exception: diff --git a/tests/test_tmpdir.py b/tests/test_tmpdir.py index 2470a2515..73fe240d0 100644 --- a/tests/test_tmpdir.py +++ b/tests/test_tmpdir.py @@ -66,7 +66,7 @@ def test_docker_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None: "tmp_outdir_prefix": tmp_outdir_prefix, } ) - job = next(clt.job({}, None, runtime_context)) + job = next(clt.job({}, lambda output, process_status: None, runtime_context)) assert isinstance(job, JobBase) assert job.stagedir and job.stagedir.startswith(tmpdir_prefix) assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix) @@ -106,7 +106,7 @@ def test_commandLineTool_job_tmpdir_prefix(tmp_path: Path) -> None: "tmp_outdir_prefix": tmp_outdir_prefix, } ) - job = next(clt.job({}, None, runtime_context)) + job = next(clt.job({}, lambda output, process_status: None, runtime_context)) assert isinstance(job, JobBase) assert job.stagedir and job.stagedir.startswith(tmpdir_prefix) assert job.tmpdir and job.tmpdir.startswith(tmpdir_prefix)