Skip to content

Commit a774d7f

Browse files
authored
Merge pull request #288 from common-workflow-language/mypy0.470
upgrade to mypy 0.470
2 parents 648c525 + 5054961 commit a774d7f

File tree

9 files changed

+70
-39
lines changed

9 files changed

+70
-39
lines changed

cwltool/draft2tool.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ def run(self, **kwargs): # type: (**Any) -> None
6060
e, exc_info=kwargs.get('debug'))
6161
self.output_callback({}, "permanentFail")
6262

63-
def job(self, joborder, output_callback, **kwargs):
64-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator[ExpressionTool.ExpressionJob, None, None]
65-
builder = self._init_job(joborder, **kwargs)
63+
def job(self,
64+
job_order, # type: Dict[Text, Text]
65+
output_callbacks, # type: Callable[[Any, Any], Any]
66+
**kwargs # type: Any
67+
):
68+
# type: (...) -> Generator[ExpressionTool.ExpressionJob, None, None]
69+
builder = self._init_job(job_order, **kwargs)
6670

6771
j = ExpressionTool.ExpressionJob()
6872
j.builder = builder
6973
j.script = self.tool["expression"]
70-
j.output_callback = output_callback
74+
j.output_callback = output_callbacks
7175
j.requirements = self.requirements
7276
j.hints = self.hints
7377
j.outdir = None
@@ -165,8 +169,12 @@ def makePathMapper(self, reffiles, stagedir, **kwargs):
165169
dockerReq, _ = self.get_requirement("DockerRequirement")
166170
return PathMapper(reffiles, kwargs["basedir"], stagedir)
167171

168-
def job(self, joborder, output_callback, **kwargs):
169-
# type: (Dict[Text, Text], Callable[..., Any], **Any) -> Generator[Union[CommandLineJob, CallbackJob], None, None]
172+
def job(self,
173+
job_order, # type: Dict[Text, Text]
174+
output_callbacks, # type: Callable[[Any, Any], Any]
175+
**kwargs # type: Any
176+
):
177+
# type: (...) -> Generator[Union[CommandLineJob, CallbackJob], None, None]
170178

171179
jobname = uniquename(kwargs.get("name", shortname(self.tool.get("id", "job"))))
172180

@@ -175,7 +183,7 @@ def job(self, joborder, output_callback, **kwargs):
175183
cacheargs["outdir"] = "/out"
176184
cacheargs["tmpdir"] = "/tmp"
177185
cacheargs["stagedir"] = "/stage"
178-
cachebuilder = self._init_job(joborder, **cacheargs)
186+
cachebuilder = self._init_job(job_order, **cacheargs)
179187
cachebuilder.pathmapper = PathMapper(cachebuilder.files,
180188
kwargs["basedir"],
181189
cachebuilder.stagedir,
@@ -222,7 +230,7 @@ def job(self, joborder, output_callback, **kwargs):
222230
cachebuilder.outdir = jobcache
223231

224232
_logger.info("[job %s] Using cached output in %s", jobname, jobcache)
225-
yield CallbackJob(self, output_callback, cachebuilder, jobcache)
233+
yield CallbackJob(self, output_callbacks, cachebuilder, jobcache)
226234
return
227235
else:
228236
_logger.info("[job %s] Output of job will be cached in %s", jobname, jobcache)
@@ -231,19 +239,19 @@ def job(self, joborder, output_callback, **kwargs):
231239
kwargs["outdir"] = jobcache
232240
open(jobcachepending, "w").close()
233241

234-
def rm_pending_output_callback(output_callback, jobcachepending,
242+
def rm_pending_output_callback(output_callbacks, jobcachepending,
235243
outputs, processStatus):
236244
if processStatus == "success":
237245
os.remove(jobcachepending)
238-
output_callback(outputs, processStatus)
246+
output_callbacks(outputs, processStatus)
239247

240-
output_callback = cast(
248+
output_callbacks = cast(
241249
Callable[..., Any], # known bug in mypy
242250
# https://github.com/python/mypy/issues/797
243-
partial(rm_pending_output_callback, output_callback,
251+
partial(rm_pending_output_callback, output_callbacks,
244252
jobcachepending))
245253

246-
builder = self._init_job(joborder, **kwargs)
254+
builder = self._init_job(job_order, **kwargs)
247255

248256
reffiles = copy.deepcopy(builder.files)
249257

@@ -265,7 +273,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
265273
j.name,
266274
self.tool.get("id", ""),
267275
u" as part of %s" % kwargs["part_of"] if "part_of" in kwargs else "")
268-
_logger.debug(u"[job %s] %s", j.name, json.dumps(joborder, indent=4))
276+
_logger.debug(u"[job %s] %s", j.name, json.dumps(job_order, indent=4))
269277

270278
builder.pathmapper = None
271279
make_path_mapper_kwargs = kwargs
@@ -377,7 +385,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
377385
j.collect_outputs = partial(
378386
self.collect_output_ports, self.tool["outputs"], builder,
379387
compute_checksum=kwargs.get("compute_checksum", True))
380-
j.output_callback = output_callback
388+
j.output_callback = output_callbacks
381389

382390
yield j
383391

cwltool/factory.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ def __call__(self, **kwargs):
3434

3535

3636
class Factory(object):
37-
def __init__(self, makeTool=workflow.defaultMakeTool,
38-
executor=main.single_job_executor,
39-
**execkwargs):
40-
# type: (tCallable[[Dict[Text, Any], Any], Process],tCallable[...,Tuple[Dict[Text,Any], Text]], **Any) -> None
37+
def __init__(self,
38+
makeTool=workflow.defaultMakeTool, # type: tCallable[[Any], Process]
39+
# should be tCallable[[Dict[Text, Any], Any], Process] ?
40+
executor=main.single_job_executor, # type: tCallable[...,Tuple[Dict[Text,Any], Text]]
41+
**execkwargs # type: Any
42+
):
43+
# type: (...) -> None
4144
self.makeTool = makeTool
4245
self.executor = executor
4346
self.execkwargs = execkwargs

cwltool/job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
206206

207207
scr, _ = get_feature(self, "ShellCommandRequirement")
208208

209+
shouldquote = None # type: Callable[[Any], Any]
209210
if scr:
210211
shouldquote = lambda x: False
211212
else:

cwltool/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
182182
return parser
183183

184184

185-
def single_job_executor(t, job_order_object, **kwargs):
186-
# type: (Process, Dict[Text, Any], **Any) -> Tuple[Dict[Text, Any], Text]
185+
def single_job_executor(t, # type: Process
186+
job_order_object, # type: Dict[Text, Any]
187+
**kwargs # type: Any
188+
):
189+
# type: (...) -> Tuple[Dict[Text, Any], Text]
187190
final_output = []
188191
final_status = []
189192

cwltool/process.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,12 @@ def visit(self, op): # type: (Callable[[Dict[Text, Any]], None]) -> None
599599
op(self.tool)
600600

601601
@abc.abstractmethod
602-
def job(self, job_order, output_callbacks, **kwargs):
603-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator[Any, None, None]
602+
def job(self,
603+
job_order, # type: Dict[Text, Text]
604+
output_callbacks, # type: Callable[[Any, Any], Any]
605+
**kwargs # type: Any
606+
):
607+
# type: (...) -> Generator[Any, None, None]
604608
return None
605609

606610

cwltool/workflow.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
WorkflowStateItem = namedtuple('WorkflowStateItem', ['parameter', 'value'])
2323

2424

25-
def defaultMakeTool(toolpath_object, **kwargs):
26-
# type: (Dict[Text, Any], **Any) -> Process
25+
def defaultMakeTool(toolpath_object, # type: Dict[Text, Any]
26+
**kwargs # type: Any
27+
):
28+
# type: (...) -> Process
2729
if not isinstance(toolpath_object, dict):
2830
raise WorkflowException(u"Not a dict: `%s`" % toolpath_object)
2931
if "class" in toolpath_object:
@@ -436,15 +438,19 @@ def __init__(self, toolpath_object, **kwargs):
436438

437439
# TODO: statically validate data links instead of doing it at runtime.
438440

439-
def job(self, joborder, output_callback, **kwargs):
440-
# type: (Dict[Text, Text], Callable[[Any, Any], Any], **Any) -> Generator
441-
builder = self._init_job(joborder, **kwargs)
441+
def job(self,
442+
job_order, # type: Dict[Text, Text]
443+
output_callbacks, # type: Callable[[Any, Any], Any]
444+
**kwargs # type: Any
445+
):
446+
# type: (...) -> Generator[Any, None, None]
447+
builder = self._init_job(job_order, **kwargs)
442448
wj = WorkflowJob(self, **kwargs)
443449
yield wj
444450

445451
kwargs["part_of"] = u"workflow %s" % wj.name
446452

447-
for w in wj.job(builder.job, output_callback, **kwargs):
453+
for w in wj.job(builder.job, output_callbacks, **kwargs):
448454
yield w
449455

450456
def visit(self, op):
@@ -561,17 +567,23 @@ def receive_output(self, output_callback, jobout, processStatus):
561567
processStatus = "permanentFail"
562568
output_callback(output, processStatus)
563569

564-
def job(self, joborder, output_callback, **kwargs):
565-
# type: (Dict[Text, Any], Callable[...,Any], **Any) -> Generator
570+
def job(self,
571+
job_order, # type: Dict[Text, Text]
572+
output_callbacks, # type: Callable[[Any, Any], Any]
573+
**kwargs # type: Any
574+
):
575+
# type: (...) -> Generator[Any, None, None]
566576
for i in self.tool["inputs"]:
567577
p = i["id"]
568578
field = shortname(p)
569-
joborder[field] = joborder[i["id"]]
570-
del joborder[i["id"]]
579+
job_order[field] = job_order[i["id"]]
580+
del job_order[i["id"]]
571581

572582
try:
573-
for t in self.embedded_tool.job(joborder,
574-
functools.partial(self.receive_output, output_callback),
583+
for t in self.embedded_tool.job(job_order,
584+
functools.partial(
585+
self.receive_output,
586+
output_callbacks),
575587
**kwargs):
576588
yield t
577589
except WorkflowException:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ ruamel.yaml==0.13.7
33
rdflib==4.2.1
44
rdflib-jsonld==0.4.0
55
shellescape==3.4.1
6-
schema-salad>=2.1.20161227155225,<3
6+
schema-salad>=2.1.20170208112505,<3
77
typing==3.5.2.2 ; python_version>="2.7"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'ruamel.yaml >= 0.12.4',
4848
'rdflib >= 4.2.0, < 4.3.0',
4949
'shellescape >= 3.4.1, < 3.5',
50-
'schema-salad >= 2.2.20170111180227, < 3',
50+
'schema-salad >= 2.2.20170208112505, < 3',
5151
'typing >= 3.5.2, < 3.6'
5252
],
5353
test_suite='tests',

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
#envlist = py35-lint,py34-lint,py33-lint,py27-lint,py35-unit,py34-unit,py33-unit,py27-unit
3-
envlist = py27-lint, py27-unit, pip27-pipconflictchecker, py35-mypy
3+
envlist = py27-lint, py27-unit, py27-pipconflictchecker, py35-mypy
44
skipsdist = True
55

66
[tox:travis]
@@ -14,7 +14,7 @@ deps = -rrequirements.txt
1414
commands = make mypy
1515
whitelist_externals = make
1616
deps =
17-
mypy-lang>=0.4.4
17+
mypy>=0.470
1818
typed-ast
1919
-rrequirements.txt
2020

0 commit comments

Comments
 (0)