Skip to content

Commit 7d24e1b

Browse files
author
Anton Khodak
committed
Add type annotations to Executor class members
1 parent 0971aea commit 7d24e1b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

cwltool/executors.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import os
66
from abc import ABCMeta, abstractmethod
77

8-
from typing import Dict, Text, Any
8+
from typing import Dict, Text, Any, Tuple, Set, List
99

1010
from cwltool.builder import Builder
1111
from cwltool.errors import WorkflowException
1212
from cwltool.mutation import MutationManager
13+
from cwltool.job import JobBase
1314
from cwltool.process import relocateOutputs, cleanIntermediate, Process
1415

1516

@@ -24,9 +25,10 @@ class JobExecutor(object):
2425
__metaclass__ = ABCMeta
2526

2627
def __init__(self):
27-
self.final_output = []
28-
self.final_status = []
29-
self.output_dirs = set()
28+
# type: (...) -> None
29+
self.final_output = [] # type: List
30+
self.final_status = [] # type: List
31+
self.output_dirs = set() # type: Set
3032

3133
def __call__(self, *args, **kwargs):
3234
return self.execute(*args, **kwargs)
@@ -38,17 +40,18 @@ def output_callback(self, out, processStatus):
3840
@abstractmethod
3941
def run_jobs(self,
4042
t, # type: Process
41-
job_order_object, # type: Dict[Text, Any],
43+
job_order_object, # type: Dict[Text, Any]
4244
logger,
4345
**kwargs # type: Any
4446
):
4547
pass
4648

4749
def execute(self, t, # type: Process
48-
job_order_object, # type: Dict[Text, Any],
50+
job_order_object, # type: Dict[Text, Any]
4951
logger=_logger,
5052
**kwargs # type: Any
5153
):
54+
# type: (...) -> Tuple[Dict[Text, Any], Text]
5255

5356
if "basedir" not in kwargs:
5457
raise WorkflowException("Must provide 'basedir' in kwargs")
@@ -87,7 +90,7 @@ def execute(self, t, # type: Process
8790
class SingleJobExecutor(JobExecutor):
8891
def run_jobs(self,
8992
t, # type: Process
90-
job_order_object, # type: Dict[Text, Any],
93+
job_order_object, # type: Dict[Text, Any]
9194
logger,
9295
**kwargs # type: Any
9396
):
@@ -120,7 +123,11 @@ def __init__(self):
120123
self.threads = set()
121124
self.exceptions = []
122125

123-
def run_job(self, job, **kwargs):
126+
def run_job(self,
127+
job, # type: JobBase
128+
**kwargs # type: Any
129+
):
130+
# type: (...) -> None
124131
def runner():
125132
try:
126133
job.run(**kwargs)
@@ -136,13 +143,13 @@ def runner():
136143
self.threads.add(thread)
137144
thread.start()
138145

139-
def wait_for_next_completion(self):
146+
def wait_for_next_completion(self): # type: () -> None
140147
if self.exceptions:
141148
raise self.exceptions[0]
142149

143150
def run_jobs(self,
144151
t, # type: Process
145-
job_order_object, # type: Dict[Text, Any],
152+
job_order_object, # type: Dict[Text, Any]
146153
logger,
147154
**kwargs # type: Any
148155
):

0 commit comments

Comments
 (0)