Skip to content

Commit 0434297

Browse files
committed
Address mypy.
Cruft. Cruft.
1 parent bf2aa5d commit 0434297

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

cwltool/builder.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Any,
88
Callable,
99
Dict,
10+
Iterable,
1011
List,
1112
MutableMapping,
1213
MutableSequence,
@@ -425,21 +426,35 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
425426
if isinstance(sfname, str):
426427
d_location = cast(str, datum["location"])
427428
sf_location = None
428-
for existing_processed_secondaryfile in datum.get(
429-
"secondaryFiles", []
430-
):
431-
if (
432-
os.path.basename(
433-
existing_processed_secondaryfile.get(
434-
"location", ""
435-
)
436-
)
437-
== sfname
438-
):
439-
# the secondary file has already been processed; use established location
440-
sf_location = existing_processed_secondaryfile[
441-
"location"
442-
]
429+
if isinstance(datum, MutableMapping) and datum.get("secondaryFiles"):
430+
if isinstance(datum["secondaryFiles"], Iterable):
431+
for existing_processed_secondaryfile in datum[
432+
"secondaryFiles"
433+
]:
434+
if isinstance(
435+
existing_processed_secondaryfile,
436+
MutableMapping,
437+
):
438+
existing_processed_location = existing_processed_secondaryfile.get(
439+
"location"
440+
)
441+
if (
442+
existing_processed_location
443+
and isinstance(
444+
existing_processed_location, str
445+
)
446+
):
447+
if (
448+
os.path.basename(
449+
existing_processed_location
450+
)
451+
== sfname
452+
):
453+
# the secondary file has already been processed;
454+
# use established location
455+
sf_location = existing_processed_secondaryfile[
456+
"location"
457+
]
443458
if not sf_location:
444459
if "/" in d_location:
445460
sf_location = (
@@ -490,7 +505,7 @@ def addsf(
490505
sfname,
491506
)
492507
elif discover_secondaryFiles and self.fs_access.exists(
493-
sf_location
508+
cast(str, sf_location)
494509
):
495510
addsf(
496511
cast(

0 commit comments

Comments
 (0)