3535
3636def _sanitize_label (label : str ) -> str :
3737 """Escape characters that have special meaning in Mermaid labels."""
38- label = label .replace ('"' , ' #quot;' )
38+ label = label .replace ('"' , " #quot;" )
3939 for ch in "()[]{}<>" :
4040 label = label .replace (ch , f"#{ ord (ch )} ;" )
4141 return label
@@ -85,7 +85,9 @@ def workflow_to_mermaid(
8585 input_ids [inp_label ] = node_id
8686 label = _sanitize_label (inp_label )
8787 type_str = _input_type_str (inp )
88- input_lines [inp_label ] = _node_line (node_id , f"{ label } <br/><i>{ type_str } </i>" , STEP_TYPE_SHAPES .get (type_str , SHAPE_INPUT ))
88+ input_lines [inp_label ] = _node_line (
89+ node_id , f"{ label } <br/><i>{ type_str } </i>" , STEP_TYPE_SHAPES .get (type_str , SHAPE_INPUT )
90+ )
8991
9092 step_ids : dict [str , str ] = {}
9193 step_lines : dict [str , str ] = {}
@@ -96,7 +98,7 @@ def workflow_to_mermaid(
9698
9799 tool_id = step .tool_id
98100 if tool_id and tool_id .startswith (MAIN_TS_PREFIX ):
99- tool_id = tool_id [len (MAIN_TS_PREFIX ):]
101+ tool_id = tool_id [len (MAIN_TS_PREFIX ) :]
100102
101103 label = _sanitize_label (step .label or step .id or (f"tool:{ tool_id } " if tool_id else str (i )))
102104 step_type = step .type_ .value if step .type_ else "tool"
@@ -141,8 +143,8 @@ def workflow_to_mermaid(
141143 continue
142144 sources = step_input .source if isinstance (step_input .source , list ) else [step_input .source ]
143145 for source in sources :
144- ref = nf2 .resolve_source (source )
145- source_id = input_ids .get (ref .step_label ) or step_ids .get (ref .step_label )
146+ source_ref = nf2 .resolve_source (source )
147+ source_id = input_ids .get (source_ref .step_label ) or step_ids .get (source_ref .step_label )
146148 if source_id :
147149 edge_key = (source_id , node_id )
148150 if edge_key not in seen_edges :
0 commit comments