From 4c7a0cc3d8ec6efb64f198a3d6786104d6e72bf7 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 20 Jan 2025 15:15:27 +0000 Subject: [PATCH] Add type annotations --- lib/galaxy/managers/workflows.py | 7 +++++-- lib/galaxy/tool_util/cwl/parser.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index ecb0b7a719ae..162596abb1ff 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -46,7 +46,10 @@ joinedload, subqueryload, ) -from typing_extensions import Annotated +from typing_extensions import ( + Annotated, + TypeAlias, +) from galaxy import ( exceptions, @@ -1827,7 +1830,7 @@ def __module_from_dict( self.add_item_annotation(sa_session, trans.get_user(), step, annotation) # Stick this in the step temporarily - DictConnection = Dict[str, Union[int, str]] + DictConnection: TypeAlias = Dict[str, Union[int, str]] temp_input_connections: Dict[str, Union[List[DictConnection], DictConnection]] = step_dict.get( "input_connections", {} ) diff --git a/lib/galaxy/tool_util/cwl/parser.py b/lib/galaxy/tool_util/cwl/parser.py index e4a4ff83fb20..5533261c560c 100644 --- a/lib/galaxy/tool_util/cwl/parser.py +++ b/lib/galaxy/tool_util/cwl/parser.py @@ -15,6 +15,7 @@ from typing import ( Dict, List, + Optional, overload, Union, ) @@ -531,7 +532,7 @@ class WorkflowProxy: def __init__(self, workflow, workflow_path=None): self._workflow = workflow self._workflow_path = workflow_path - self._step_proxies = None + self._step_proxies: Optional[List[Union[SubworkflowStepProxy, ToolStepProxy]]] = None @property def cwl_id(self): @@ -562,7 +563,7 @@ def get_outputs_for_label(self, label): def tool_reference_proxies(self): """Fetch tool source definitions for all referenced tools.""" - references = [] + references: List[ToolProxy] = [] for step in self.step_proxies(): references.extend(step.tool_reference_proxies()) return references