diff --git a/src/toil/cwl/cwltoil.py b/src/toil/cwl/cwltoil.py index 51ad20d8b9..ef38a105f6 100644 --- a/src/toil/cwl/cwltoil.py +++ b/src/toil/cwl/cwltoil.py @@ -54,7 +54,7 @@ TypeVar, Union, cast, - Sequence, + Sequence, Literal, ) from urllib.error import HTTPError from urllib.parse import quote, unquote, urlparse, urlsplit @@ -1857,7 +1857,7 @@ def extract_files( if location in fileindex: file_metadata["location"] = fileindex[location] - return + return None if not location and file_metadata["path"]: file_metadata["location"] = location = schema_salad.ref_resolver.file_uri( cast(str, file_metadata["path"]) @@ -1944,7 +1944,7 @@ def visit_files( :param log_level: Log imported files at the given level. """ - func_return = list() + func_return: List[Any] = list() tool_id = cwl_object.get("id", str(cwl_object)) if cwl_object else "" logger.debug("Importing files for %s", tool_id) @@ -3653,7 +3653,7 @@ class CWLStartJob(CWLNamedJob): def __init__( self, - inputs: Promised[Tuple[CWLObjectType, CWLObjectType]], + inputs: Promised[Tuple[CWLObjectType, Process]], runtime_context: cwltool.context.RuntimeContext, **kwargs: Any, ) -> None: @@ -3765,7 +3765,7 @@ def import_workflow_inputs( # always get a FileID out. def file_import_function(url: str) -> FileID: logger.log(log_level, "Loading %s...", url) - return cast(FileID, jobstore.import_file(url, symlink=True)) + return jobstore.import_file(url, symlink=True) # Import all the input files, some of which may be missing optional # files. @@ -3835,6 +3835,8 @@ def visitSteps( f"Unsupported type encountered in workflow " f"traversal: {type(cmdline_tool)}" ) + # Satisfy mypy, but this branch should never be reached in practice + return [] def rm_unprocessed_secondary_files(job_params: Any) -> None: diff --git a/src/toil/job.py b/src/toil/job.py index 2789488b46..4a1bbc15e7 100644 --- a/src/toil/job.py +++ b/src/toil/job.py @@ -3874,8 +3874,8 @@ class ImportsJob(Job): def __init__( self, file_to_data: Dict[str, FileMetadata], - import_workers_threshold, - **kwargs: Any, + import_workers_threshold: ParseableIndivisibleResource, + **kwargs: Any ): """ Job to take the inputs from the WDL workflow and import them on a worker instead of a leader. Assumes all local and cloud files are accessible. diff --git a/src/toil/wdl/wdltoil.py b/src/toil/wdl/wdltoil.py index 5811bc209c..bbb1de2045 100755 --- a/src/toil/wdl/wdltoil.py +++ b/src/toil/wdl/wdltoil.py @@ -1146,7 +1146,7 @@ def convert_file_to_uri(file: WDL.Value.File) -> WDL.Value.File: Calls import_filename to detect if a potential URI exists and imports it. Will modify the File object value to the new URI and tack on the virtualized file. """ candidate_uri = file_to_data[file.value][0] - file_id = file_to_id.get(candidate_uri) + file_id = file_to_id[candidate_uri] # Work out what the basename for the file was file_basename = os.path.basename(urlsplit(candidate_uri).path) @@ -4877,7 +4877,7 @@ def __init__( self, task_path: str, inputs: WDLBindings, - import_data: Promised[Tuple[Dict[str, FileID]], Dict[str, FileMetadata]], + import_data: Promised[Tuple[Dict[str, FileID], Dict[str, FileMetadata]]], **kwargs: Any, ) -> None: """ @@ -4915,9 +4915,9 @@ def __init__( target: Union[WDL.Tree.Workflow, WDL.Tree.Task], inputs: WDLBindings, wdl_options: WDLContext, - inputs_search_path, - import_remote_files, - import_workers_threshold, + inputs_search_path: List[str], + import_remote_files: bool, + import_workers_threshold: ParseableIndivisibleResource, **kwargs: Any, ): """ @@ -4960,13 +4960,13 @@ def run(self, file_store: AbstractFileStore) -> Promised[WDLBindings]: def make_root_job( target: WDL.Tree.Workflow | WDL.Tree.Task, inputs: WDLBindings, - inputs_search_path: list[str], + inputs_search_path: List[str], toil: Toil, wdl_options: WDLContext, options: Namespace, ) -> WDLSectionJob: if options.run_imports_on_workers: - root_job = WDLImportWrapper( + root_job: WDLSectionJob = WDLImportWrapper( target, inputs, wdl_options=wdl_options,