Skip to content

Commit f64c73a

Browse files
Apply suggestions from code review
1 parent 85578b8 commit f64c73a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/crewai/flow/utils.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def visit_Return(self, node):
9797
def calculate_node_levels(flow: Any) -> Dict[str, int]:
9898
"""
9999
Calculate the hierarchical level of each node in the flow.
100+
101+
100102
Performs a breadth-first traversal of the flow graph to assign levels
101103
to nodes, starting with start methods at level 0.
102104
@@ -109,13 +111,13 @@ def calculate_node_levels(flow: Any) -> Dict[str, int]:
109111
-------
110112
Dict[str, int]
111113
Dictionary mapping method names to their hierarchical levels.
112-
Notes
114+
115+
Notes
113116
-----
114117
- Start methods are assigned level 0
115118
- Each subsequent connected node is assigned level = parent_level + 1
116119
- Handles both OR and AND conditions for listeners
117120
- Processes router paths separately
118-
119121
"""
120122
levels: Dict[str, int] = {}
121123
queue: Deque[str] = deque()
@@ -219,7 +221,10 @@ def build_ancestor_dict(flow: Any) -> Dict[str, Set[str]]:
219221

220222

221223
def dfs_ancestors(
222-
node: str, ancestors: Dict[str, Set[str]], visited: Set[str], flow: Any
224+
node: str,
225+
ancestors: Dict[str, Set[str]],
226+
visited: Set[str],
227+
flow: Any
223228
) -> None:
224229
"""
225230
Perform depth-first search to build ancestor relationships.
@@ -263,9 +268,7 @@ def dfs_ancestors(
263268
dfs_ancestors(listener_name, ancestors, visited, flow)
264269

265270

266-
def is_ancestor(
267-
node: str, ancestor_candidate: str, ancestors: Dict[str, Set[str]]
268-
) -> bool:
271+
def is_ancestor(node: str, ancestor_candidate: str, ancestors: Dict[str, Set[str]]) -> bool:
269272
"""
270273
Check if one node is an ancestor of another.
271274
@@ -330,9 +333,7 @@ def build_parent_children_dict(flow: Any) -> Dict[str, List[str]]:
330333
return parent_children
331334

332335

333-
def get_child_index(
334-
parent: str, child: str, parent_children: Dict[str, List[str]]
335-
) -> int:
336+
def get_child_index(parent: str, child: str, parent_children: Dict[str, List[str]]) -> int:
336337
"""
337338
Get the index of a child node in its parent's sorted children list.
338339

0 commit comments

Comments
 (0)