Skip to content

Commit a574f47

Browse files
committed
freshen cwltool/subgraph.py
1 parent 23ae047 commit a574f47

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

cwltool/subgraph.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import urllib
22
from collections import namedtuple
3-
from typing import Any, Dict, MutableMapping, MutableSequence, Optional, Set, Tuple
3+
from typing import Dict, MutableMapping, MutableSequence, Optional, Set, Tuple, cast
44

55
from ruamel.yaml.comments import CommentedMap
66

7-
from .utils import aslist
7+
from .utils import CWLObjectType, aslist
88
from .workflow import Workflow
99

1010
Node = namedtuple("Node", ("up", "down", "type"))
@@ -16,11 +16,8 @@
1616

1717

1818
def subgraph_visit(
19-
current, # type: str
20-
nodes, # type: MutableMapping[str, Node]
21-
visited, # type: Set[str]
22-
direction, # type: str
23-
): # type: (...) -> None
19+
current: str, nodes: MutableMapping[str, Node], visited: Set[str], direction: str,
20+
) -> None:
2421

2522
if current in visited:
2623
return
@@ -34,8 +31,7 @@ def subgraph_visit(
3431
subgraph_visit(c, nodes, visited, direction)
3532

3633

37-
def declare_node(nodes, nodeid, tp):
38-
# type: (Dict[str, Node], str, Optional[str]) -> Node
34+
def declare_node(nodes: Dict[str, Node], nodeid: str, tp: Optional[str]) -> Node:
3935
if nodeid in nodes:
4036
n = nodes[nodeid]
4137
if n.type is None:
@@ -89,7 +85,7 @@ def get_subgraph(roots: MutableSequence[str], tool: Workflow) -> CommentedMap:
8985
else:
9086
subgraph_visit(r, nodes, visited_down, DOWN)
9187

92-
def find_step(stepid): # type: (str) -> Optional[MutableMapping[str, Any]]
88+
def find_step(stepid: str) -> Optional[CWLObjectType]:
9389
for st in tool.steps:
9490
if st.tool["id"] == stepid:
9591
return st.tool
@@ -113,7 +109,9 @@ def find_step(stepid): # type: (str) -> Optional[MutableMapping[str, Any]]
113109
if nodes[v].type == STEP:
114110
wfstep = find_step(v)
115111
if wfstep is not None:
116-
for inp in wfstep["inputs"]:
112+
for inp in cast(
113+
MutableSequence[CWLObjectType], wfstep["inputs"]
114+
):
117115
if u in inp["source"]:
118116
rewire[u] = (rn, inp["type"])
119117
break

0 commit comments

Comments
 (0)