From 55380deaa8a70200fd61f1073c1a83d2ccec6dbf Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Wed, 17 Nov 2021 13:18:15 +0000 Subject: [PATCH] Typing fixes after rebase --- lib/galaxy/managers/workflows.py | 7 +++---- lib/galaxy/tools/evaluation.py | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 29b0855e2025..2d22b423ff92 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -356,10 +356,9 @@ def normalize_workflow_format(self, trans, as_dict): # create a temporary file for the workflow if it is provided # as JSON, to make it parseable by the WorkflowProxy if workflow_path is None: - f = tempfile.NamedTemporaryFile(delete=False) - json.dump(as_dict, f) - workflow_path = f.name - f.close() + with tempfile.NamedTemporaryFile(mode="w+", delete=False) as f: + json.dump(as_dict, f) + workflow_path = f.name if object_id: workflow_path += "#" + object_id wf_proxy = workflow_proxy(workflow_path) diff --git a/lib/galaxy/tools/evaluation.py b/lib/galaxy/tools/evaluation.py index 3e94fd09d95a..d03a401ed680 100644 --- a/lib/galaxy/tools/evaluation.py +++ b/lib/galaxy/tools/evaluation.py @@ -3,7 +3,7 @@ import os import shlex import tempfile -from typing import Any, cast, Dict, List +from typing import Any, cast, Dict, List, Optional, Union from galaxy import model from galaxy.files import ProvidesUserFileSourcesUserContext @@ -249,9 +249,8 @@ def wrap_input(input_values, input): ) input_values[input.name] = wrapper elif isinstance(input, FieldTypeToolParameter): - if value is None: - field_wrapper = None - else: + field_wrapper: Optional[Union[InputValueWrapper, DatasetFilenameWrapper]] = None + if value: assert "value" in value, value assert "src" in value, value src = value["src"] @@ -260,7 +259,7 @@ def wrap_input(input_values, input): elif src == "hda": field_wrapper = DatasetFilenameWrapper(value["value"], datatypes_registry=self.app.datatypes_registry, - tool=self, + tool=self.tool, name=input.name) else: raise ValueError(f"src should be 'json' or 'hda' but is '{src}'")