Skip to content

Commit e346b51

Browse files
author
Peter Amstutz
committed
Fixing tests WIP
1 parent 226d92a commit e346b51

18 files changed

+82
-91
lines changed

cwltool/argparser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import argparse
44
import os
5-
from typing import Any, AnyStr, Dict, List, Optional, Sequence, Union, cast, MutableMapping
5+
from typing import (Any, AnyStr, Dict, List, Optional, Sequence,
6+
Union, cast, MutableMapping, MutableSequence)
67

78
from typing_extensions import Text # pylint: disable=unused-import
89
# move to a regular typing import when Python 3.3-3.6 is no longer supported
@@ -381,7 +382,7 @@ def add_argument(toolparser, name, inptype, records, description="",
381382
flag = "--"
382383

383384
required = True
384-
if isinstance(inptype, list):
385+
if isinstance(inptype, MutableSequence):
385386
if inptype[0] == "null":
386387
required = False
387388
if len(inptype) == 2:

cwltool/builder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import copy
44
import logging
5-
from typing import Any, Callable, Dict, List, Optional, Set, Union, Tuple, MutableMapping
5+
from typing import (Any, Callable, Dict, List, Optional, Set, Union,
6+
Tuple, MutableMapping, MutableSequence)
67
from typing_extensions import Text, Type, TYPE_CHECKING # pylint: disable=unused-import
78
# move to a regular typing import when Python 3.3-3.6 is no longer supported
89

@@ -221,7 +222,7 @@ def bind_input(self,
221222
value_from_expression = True
222223

223224
# Handle union types
224-
if isinstance(schema["type"], list):
225+
if isinstance(schema["type"], MutableSequence):
225226
bound_input = False
226227
for t in schema["type"]:
227228
if isinstance(t, string_types) and self.names.has_name(t, ""):
@@ -373,7 +374,7 @@ def generate_arg(self, binding): # type: (Dict[Text, Any]) -> List[Text]
373374
raise WorkflowException("'separate' option can not be specified without prefix")
374375

375376
argl = [] # type: List[Dict[Text,Text]]
376-
if isinstance(value, list):
377+
if isinstance(value, MutableSequence):
377378
if binding.get("itemSeparator") and value:
378379
argl = [binding["itemSeparator"].join([self.tostr(v) for v in value])]
379380
elif binding.get("valueFrom"):
@@ -410,7 +411,7 @@ def do_eval(self, ex, context=None, recursive=False, strip_whitespace=True):
410411
if isinstance(ex, MutableMapping):
411412
return {k: self.do_eval(v, context, recursive)
412413
for k, v in iteritems(ex)}
413-
if isinstance(ex, list):
414+
if isinstance(ex, MutableSequence):
414415
return [self.do_eval(v, context, recursive)
415416
for v in ex]
416417

cwltool/checker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import namedtuple
2-
from typing import Any, Dict, List, Optional, MutableMapping
2+
from typing import Any, Dict, List, Optional, MutableMapping, MutableSequence
33
from typing_extensions import Text # pylint: disable=unused-import
44
# move to a regular typing import when Python 3.3-3.6 is no longer supported
55

@@ -46,7 +46,7 @@ def merge_flatten_type(src):
4646
"""Return the merge flattened type of the source type
4747
"""
4848

49-
if isinstance(src, list):
49+
if isinstance(src, MutableSequence):
5050
return [merge_flatten_type(t) for t in src]
5151
if isinstance(src, MutableMapping) and src.get("type") == "array":
5252
return src
@@ -79,7 +79,7 @@ def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -
7979
return False
8080
return True
8181
return can_assign_src_to_sink(src["type"], sink["type"], strict)
82-
elif isinstance(src, list):
82+
elif isinstance(src, MutableSequence):
8383
if strict:
8484
for t in src:
8585
if not can_assign_src_to_sink(t, sink):
@@ -90,7 +90,7 @@ def can_assign_src_to_sink(src, sink, strict=False): # type: (Any, Any, bool) -
9090
if can_assign_src_to_sink(t, sink):
9191
return True
9292
return False
93-
elif isinstance(sink, list):
93+
elif isinstance(sink, MutableSequence):
9494
for t in sink:
9595
if can_assign_src_to_sink(src, t):
9696
return True
@@ -227,7 +227,7 @@ def check_all_types(src_dict, sinks, sourceField):
227227
for sink in sinks:
228228
if sourceField in sink:
229229
valueFrom = sink.get("valueFrom")
230-
if isinstance(sink[sourceField], list):
230+
if isinstance(sink[sourceField], MutableSequence):
231231
srcs_of_sink = [src_dict[parm_id] for parm_id in sink[sourceField]]
232232
linkMerge = sink.get("linkMerge", ("merge_nested"
233233
if len(sink[sourceField]) > 1 else None))

cwltool/command_line_tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import threading
1313
from functools import cmp_to_key, partial
1414
from typing import (Any, Callable, Dict, Generator, List, Optional, Set, Union,
15-
cast, MutableMapping)
15+
cast, MutableMapping, MutableSequence)
1616
from typing_extensions import Text, Type, TYPE_CHECKING # pylint: disable=unused-import
1717
# move to a regular typing import when Python 3.3-3.6 is no longer supported
1818

@@ -706,7 +706,7 @@ def collect_output(self,
706706

707707
optional = False
708708
single = False
709-
if isinstance(schema["type"], list):
709+
if isinstance(schema["type"], MutableSequence):
710710
if "null" in schema["type"]:
711711
optional = True
712712
if "File" in schema["type"] or "Directory" in schema["type"]:
@@ -724,7 +724,7 @@ def collect_output(self,
724724
raise WorkflowException("Did not find output file with glob pattern: '{}'".format(globpatterns))
725725
elif not r and optional:
726726
pass
727-
elif isinstance(r, list):
727+
elif isinstance(r, MutableSequence):
728728
if len(r) > 1:
729729
raise WorkflowException("Multiple matches for output item that is a single file.")
730730
else:

cwltool/expression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import copy
44
import re
5-
from typing import Any, Dict, List, Optional, Union, MutableMapping
5+
from typing import Any, Dict, List, Optional, Union, MutableMapping, MutableSequence
66
from typing_extensions import Text # pylint: disable=unused-import
77
# move to a regular typing import when Python 3.3-3.6 is no longer supported
88
import six
@@ -130,7 +130,7 @@ def next_seg(parsed_string, remaining_string, current_value): # type: (Text, Te
130130
key = next_segment_str[2:-2].replace("\\'", "'").replace('\\"', '"')
131131

132132
if key:
133-
if isinstance(current_value, list) and key == "length" and not remaining_string[m.end(0):]:
133+
if isinstance(current_value, MutableSequence) and key == "length" and not remaining_string[m.end(0):]:
134134
return len(current_value)
135135
if not isinstance(current_value, MutableMapping):
136136
raise WorkflowException("%s is a %s, cannot index on string '%s'" % (parsed_string, type(current_value).__name__, key))
@@ -141,7 +141,7 @@ def next_seg(parsed_string, remaining_string, current_value): # type: (Text, Te
141141
key = int(next_segment_str[1:-1])
142142
except ValueError as v:
143143
raise WorkflowException(u(str(v)))
144-
if not isinstance(current_value, list):
144+
if not isinstance(current_value, MutableSequence):
145145
raise WorkflowException("%s is a %s, cannot index on int '%s'" % (parsed_string, type(current_value).__name__, key))
146146
if key >= len(current_value):
147147
raise WorkflowException("%s list index %i out of range" % (parsed_string, key))

cwltool/job.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from threading import Timer
1414
from abc import ABCMeta, abstractmethod
1515
from io import IOBase, open # pylint: disable=redefined-builtin
16-
from typing import (IO, Any, AnyStr, Callable, Dict, Iterable, List, MutableMapping,
17-
Optional, Union, cast)
16+
from typing import (IO, Any, AnyStr, Callable, Dict, Iterable, List,
17+
Optional, Union, cast, MutableMapping, MutableSequence)
1818

1919
from typing_extensions import Text, TYPE_CHECKING # pylint: disable=unused-import
2020
# move to a regular typing import when Python 3.3-3.6 is no longer supported
@@ -116,7 +116,7 @@ def deref_links(outputs): # type: (Any) -> None
116116
else:
117117
for v in outputs.values():
118118
deref_links(v)
119-
if isinstance(outputs, list):
119+
if isinstance(outputs, MutableSequence):
120120
for output in outputs:
121121
deref_links(output)
122122

@@ -523,6 +523,7 @@ def _job_popen(
523523
if stderr_path is not None:
524524
stderr = open(stderr_path, "wb")
525525

526+
print("ZZZ", commands)
526527
sproc = subprocess.Popen(commands,
527528
shell=False,
528529
close_fds=not onWindows(),

cwltool/load_tool.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import os
77
import re
88
import uuid
9-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast, MutableMapping
9+
from typing import (Any, Callable, Dict, List, Optional, Tuple,
10+
Union, cast, MutableMapping, MutableSequence)
1011
from typing_extensions import Text # pylint: disable=unused-import
1112
# move to a regular typing import when Python 3.3-3.6 is no longer supported
1213

@@ -172,7 +173,7 @@ def _convert_stdstreams_to_files(workflowobj):
172173
else:
173174
for entry in itervalues(workflowobj):
174175
_convert_stdstreams_to_files(entry)
175-
if isinstance(workflowobj, list):
176+
if isinstance(workflowobj, MutableSequence):
176177
for entry in workflowobj:
177178
_convert_stdstreams_to_files(entry)
178179

@@ -187,7 +188,7 @@ def _add_blank_ids(workflowobj):
187188
workflowobj["run"]["id"] = Text(uuid.uuid4())
188189
for entry in itervalues(workflowobj):
189190
_add_blank_ids(entry)
190-
if isinstance(workflowobj, list):
191+
if isinstance(workflowobj, MutableSequence):
191192
for entry in workflowobj:
192193
_add_blank_ids(entry)
193194

@@ -206,7 +207,7 @@ def validate_document(document_loader, # type: Loader
206207
# type: (...) -> Tuple[Loader, schema.Names, Union[Dict[Text, Any], List[Dict[Text, Any]]], Dict[Text, Any], Text]
207208
"""Validate a CWL document."""
208209

209-
if isinstance(workflowobj, list):
210+
if isinstance(workflowobj, MutableSequence):
210211
workflowobj = cmap({
211212
"$graph": workflowobj
212213
}, fn=uri)
@@ -318,7 +319,7 @@ def make_tool(document_loader, # type: Loader
318319
resolveduri = document_loader.resolve_ref(uri)[0]
319320

320321
processobj = None
321-
if isinstance(resolveduri, list):
322+
if isinstance(resolveduri, MutableSequence):
322323
for obj in resolveduri:
323324
if obj['id'].endswith('#main'):
324325
processobj = obj

cwltool/pack.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import absolute_import
22

33
import copy
4-
from typing import Any, Callable, Dict, List, Optional, Set, Union, cast, MutableMapping
4+
from typing import (Any, Callable, Dict, List, Optional, Set,
5+
Union, cast, MutableMapping, MutableSequence)
56
from typing_extensions import Text # pylint: disable=unused-import
67
# move to a regular typing import when Python 3.3-3.6 is no longer supported
78

@@ -15,7 +16,7 @@
1516

1617

1718
def flatten_deps(d, files): # type: (Any, Set[Text]) -> None
18-
if isinstance(d, list):
19+
if isinstance(d, MutableSequence):
1920
for s in d:
2021
flatten_deps(s, files)
2122
elif isinstance(d, MutableMapping):
@@ -33,7 +34,7 @@ def find_run(d, # type: Any
3334
loadref, # type: LoadRefType
3435
runs # type: Set[Text]
3536
): # type: (...) -> None
36-
if isinstance(d, list):
37+
if isinstance(d, MutableSequence):
3738
for s in d:
3839
find_run(s, loadref, runs)
3940
elif isinstance(d, MutableMapping):
@@ -46,7 +47,7 @@ def find_run(d, # type: Any
4647

4748

4849
def find_ids(d, ids): # type: (Any, Set[Text]) -> None
49-
if isinstance(d, list):
50+
if isinstance(d, MutableSequence):
5051
for s in d:
5152
find_ids(s, ids)
5253
elif isinstance(d, MutableMapping):
@@ -59,7 +60,7 @@ def find_ids(d, ids): # type: (Any, Set[Text]) -> None
5960

6061
def replace_refs(d, rewrite, stem, newstem):
6162
# type: (Any, Dict[Text, Text], Text, Text) -> None
62-
if isinstance(d, list):
63+
if isinstance(d, MutableSequence):
6364
for s, v in enumerate(d):
6465
if isinstance(v, string_types):
6566
if v in rewrite:
@@ -86,7 +87,7 @@ def replace_refs(d, rewrite, stem, newstem):
8687

8788
def import_embed(d, seen):
8889
# type: (Any, Set[Text]) -> None
89-
if isinstance(d, list):
90+
if isinstance(d, MutableSequence):
9091
for v in d:
9192
import_embed(v, seen)
9293
elif isinstance(d, MutableMapping):
@@ -116,7 +117,7 @@ def pack(document_loader, # type: Loader
116117
document_loader.idx = {}
117118
if isinstance(processobj, MutableMapping):
118119
document_loader.idx[processobj["id"]] = CommentedMap(iteritems(processobj))
119-
elif isinstance(processobj, list):
120+
elif isinstance(processobj, MutableSequence):
120121
_, frag = urllib.parse.urldefrag(uri)
121122
for po in processobj:
122123
if not frag:

cwltool/pathmapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import uuid
88
from functools import partial # pylint: disable=unused-import
99
from tempfile import NamedTemporaryFile
10-
from typing import (Any, Callable, Dict, List, MutableMapping, Optional, Set, Tuple,
11-
Union)
10+
from typing import (Any, Callable, Dict, List, MutableMapping, MutableSequence,
11+
Optional, Set, Tuple, Union)
1212
from typing_extensions import Text # pylint: disable=unused-import
1313
# move to a regular typing import when Python 3.3-3.6 is no longer supported
1414

@@ -36,7 +36,7 @@ def adjustFiles(rec, op): # type: (Any, Union[Callable[..., Any], partial[Any]]
3636
rec["path"] = op(rec["path"])
3737
for d in rec:
3838
adjustFiles(rec[d], op)
39-
if isinstance(rec, list):
39+
if isinstance(rec, MutableSequence):
4040
for d in rec:
4141
adjustFiles(d, op)
4242

0 commit comments

Comments
 (0)