uranusjr commented on code in PR #26658:
URL: https://github.com/apache/airflow/pull/26658#discussion_r985328519


##########
airflow/utils/task_group.py:
##########
@@ -453,6 +454,22 @@ def topological_sort(self, _include_subdag_tasks: bool = 
False):
 
         return graph_sorted
 
+    def get_task_dict(self) -> dict[str, AbstractOperator]:
+        """Returns a flat dictionary of task_id: AbstractOperator"""
+        task_map = {}
+        groups_to_visit = [self]
+
+        while groups_to_visit:
+            visiting = groups_to_visit.pop(0)
+
+            for child in visiting.children.values():
+                if isinstance(child, AbstractOperator):
+                    task_map[child.task_id] = child
+                elif isinstance(child, TaskGroup):

Review Comment:
   I’d add an additional `else` block below and throw a ValueError or something 
to make sure a new class does not get ignored accidentally. Also if you 
annotate `task_map` this would be handled by Mypy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to