diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index abb72160652a..516c2eea22a7 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -14,7 +14,6 @@ get_args, Iterable, List, - Literal, Optional, Tuple, Type, @@ -109,13 +108,15 @@ from galaxy.util.rules_dsl import RuleSet from galaxy.util.template import fill_template from galaxy.util.tool_shed.common_util import get_tool_shed_url_from_tool_shed_registry -from galaxy.workflow.workflow_parameter_input_definitions import get_default_parameter +from galaxy.workflow.workflow_parameter_input_definitions import ( + get_default_parameter, + INPUT_PARAMETER_TYPES, +) if TYPE_CHECKING: from galaxy.schema.invocation import InvocationMessageUnion from galaxy.workflow.run import WorkflowProgress - log = logging.getLogger(__name__) # Key into Tool state to describe invocation-specific runtime properties. @@ -125,7 +126,6 @@ # ones. RUNTIME_POST_JOB_ACTIONS_KEY = "__POST_JOB_ACTIONS__" -INPUT_PARAMETER_TYPES = Literal["text", "integer", "float", "boolean", "color", "directory_uri"] POSSIBLE_PARAMETER_TYPES: Tuple[INPUT_PARAMETER_TYPES] = get_args(INPUT_PARAMETER_TYPES) @@ -1505,7 +1505,7 @@ def get_runtime_inputs(self, step, connections: Optional[Iterable[WorkflowStepCo parameter_type = parameter_def["parameter_type"] optional = parameter_def["optional"] default_value = parameter_def.get("default", self.default_default_value) - if parameter_type not in ["text", "boolean", "integer", "float", "color", "directory_uri"]: + if parameter_type not in POSSIBLE_PARAMETER_TYPES: raise ValueError("Invalid parameter type for workflow parameters encountered.") # Optional parameters for tool input source definition. diff --git a/lib/galaxy/workflow/workflow_parameter_input_definitions.py b/lib/galaxy/workflow/workflow_parameter_input_definitions.py index 8cb3bc110b5b..ee59a87d42a9 100644 --- a/lib/galaxy/workflow/workflow_parameter_input_definitions.py +++ b/lib/galaxy/workflow/workflow_parameter_input_definitions.py @@ -13,7 +13,7 @@ TextToolParameter, ) -param_types = Literal["text", "integer", "float", "color", "boolean", "directory_uri"] +INPUT_PARAMETER_TYPES = Literal["text", "integer", "float", "boolean", "color", "directory_uri"] default_source_type = Dict[str, Union[int, float, bool, str]] tool_param_type = Union[ TextToolParameter, @@ -25,21 +25,14 @@ ] -def get_default_parameter(param_type: param_types) -> tool_param_type: +def get_default_parameter(param_type: INPUT_PARAMETER_TYPES) -> tool_param_type: """ param_type is the type of parameter we want to build up, stored_parameter_type is the parameter_type as stored in the tool state """ default_source: default_source_type = dict(name="default", label="Default Value", type=param_type, optional=False) if param_type == "text": - input_default_value: Union[ - TextToolParameter, - IntegerToolParameter, - FloatToolParameter, - BooleanToolParameter, - ColorToolParameter, - DirectoryUriToolParameter, - ] = TextToolParameter(None, default_source) + input_default_value: tool_param_type = TextToolParameter(None, default_source) elif param_type == "integer": input_default_value = IntegerToolParameter(None, default_source) elif param_type == "float":