1
1
import urllib
2
2
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
4
4
5
5
from ruamel .yaml .comments import CommentedMap
6
6
7
- from .utils import aslist
7
+ from .utils import CWLObjectType , aslist
8
8
from .workflow import Workflow
9
9
10
10
Node = namedtuple ("Node" , ("up" , "down" , "type" ))
16
16
17
17
18
18
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 :
24
21
25
22
if current in visited :
26
23
return
@@ -34,8 +31,7 @@ def subgraph_visit(
34
31
subgraph_visit (c , nodes , visited , direction )
35
32
36
33
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 :
39
35
if nodeid in nodes :
40
36
n = nodes [nodeid ]
41
37
if n .type is None :
@@ -89,7 +85,7 @@ def get_subgraph(roots: MutableSequence[str], tool: Workflow) -> CommentedMap:
89
85
else :
90
86
subgraph_visit (r , nodes , visited_down , DOWN )
91
87
92
- def find_step (stepid ): # type: ( str) -> Optional[MutableMapping[str, Any]]
88
+ def find_step (stepid : str ) -> Optional [CWLObjectType ]:
93
89
for st in tool .steps :
94
90
if st .tool ["id" ] == stepid :
95
91
return st .tool
@@ -113,7 +109,9 @@ def find_step(stepid): # type: (str) -> Optional[MutableMapping[str, Any]]
113
109
if nodes [v ].type == STEP :
114
110
wfstep = find_step (v )
115
111
if wfstep is not None :
116
- for inp in wfstep ["inputs" ]:
112
+ for inp in cast (
113
+ MutableSequence [CWLObjectType ], wfstep ["inputs" ]
114
+ ):
117
115
if u in inp ["source" ]:
118
116
rewire [u ] = (rn , inp ["type" ])
119
117
break
0 commit comments