Skip to content

Commit 345d7a5

Browse files
committed
Add type annotations
1 parent 8797f1e commit 345d7a5

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

lib/galaxy/managers/workflows.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
joinedload,
4747
subqueryload,
4848
)
49-
from typing_extensions import Annotated
49+
from typing_extensions import (
50+
Annotated,
51+
TypeAlias,
52+
)
5053

5154
from galaxy import (
5255
exceptions,
@@ -1827,7 +1830,7 @@ def __module_from_dict(
18271830
self.add_item_annotation(sa_session, trans.get_user(), step, annotation)
18281831

18291832
# Stick this in the step temporarily
1830-
DictConnection = Dict[str, Union[int, str]]
1833+
DictConnection: TypeAlias = Dict[str, Union[int, str]]
18311834
temp_input_connections: Dict[str, Union[List[DictConnection], DictConnection]] = step_dict.get(
18321835
"input_connections", {}
18331836
)

lib/galaxy/tool_util/cwl/parser.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import (
1616
Dict,
1717
List,
18+
Optional,
1819
overload,
1920
Union,
2021
)
@@ -531,7 +532,7 @@ class WorkflowProxy:
531532
def __init__(self, workflow, workflow_path=None):
532533
self._workflow = workflow
533534
self._workflow_path = workflow_path
534-
self._step_proxies = None
535+
self._step_proxies: Optional[List[Union[SubworkflowStepProxy, ToolStepProxy]]] = None
535536

536537
@property
537538
def cwl_id(self):
@@ -562,7 +563,7 @@ def get_outputs_for_label(self, label):
562563

563564
def tool_reference_proxies(self):
564565
"""Fetch tool source definitions for all referenced tools."""
565-
references = []
566+
references: List[ToolProxy] = []
566567
for step in self.step_proxies():
567568
references.extend(step.tool_reference_proxies())
568569
return references

lib/galaxy/tools/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ class ToolBox(AbstractToolBox):
458458
dependency management, etc.
459459
"""
460460

461-
def __init__(self, config_filenames, tool_root_dir, app, save_integrated_tool_panel=True):
461+
def __init__(self, config_filenames, tool_root_dir, app, save_integrated_tool_panel: bool = True):
462462
self._reload_count = 0
463463
self.tool_location_fetcher = ToolLocationFetcher()
464-
self.cache_regions = {}
464+
self.cache_regions: Dict[str, ToolDocumentCache] = {}
465465
# This is here to deal with the old default value, which doesn't make
466466
# sense in an "installed Galaxy" world.
467467
# FIXME: ./
@@ -517,7 +517,7 @@ def load_builtin_converters(self):
517517
tool.hidden = False
518518
section.elems.append_tool(tool)
519519

520-
def persist_cache(self, register_postfork=False):
520+
def persist_cache(self, register_postfork: bool = False):
521521
"""
522522
Persists any modified tool cache files to disk.
523523
@@ -561,13 +561,13 @@ def tools_by_id(self):
561561
# Deprecated method, TODO - eliminate calls to this in test/.
562562
return self._tools_by_id
563563

564-
def get_cache_region(self, tool_cache_data_dir):
564+
def get_cache_region(self, tool_cache_data_dir: Optional[str]):
565565
if self.app.config.enable_tool_document_cache and tool_cache_data_dir:
566566
if tool_cache_data_dir not in self.cache_regions:
567567
self.cache_regions[tool_cache_data_dir] = ToolDocumentCache(cache_dir=tool_cache_data_dir)
568568
return self.cache_regions[tool_cache_data_dir]
569569

570-
def create_tool(self, config_file: str, tool_cache_data_dir=None, **kwds):
570+
def create_tool(self, config_file: str, tool_cache_data_dir: Optional[str] = None, **kwds):
571571
cache = self.get_cache_region(tool_cache_data_dir)
572572
if config_file.endswith(".xml") and cache and not cache.disabled:
573573
tool_document = cache.get(config_file)

lib/galaxy/tools/execute.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from boltons.iterutils import remap
2323
from packaging.version import Version
24+
from typing_extensions import TypeAlias
2425

2526
from galaxy import model
2627
from galaxy.exceptions import ToolInputsNotOKException
@@ -52,7 +53,7 @@
5253

5354

5455
CompletedJobsT = Dict[int, Optional[model.Job]]
55-
JobCallbackT = Callable
56+
JobCallbackT: TypeAlias = Callable
5657
WorkflowResourceParametersT = Dict[str, Any]
5758
DatasetCollectionElementsSliceT = Dict[str, model.DatasetCollectionElement]
5859
DEFAULT_USE_CACHED_JOB = False

0 commit comments

Comments
 (0)