Dev-iL commented on code in PR #58062:
URL: https://github.com/apache/airflow/pull/58062#discussion_r2531528041


##########
airflow-core/src/airflow/models/serialized_dag.py:
##########
@@ -605,6 +605,17 @@ def get(cls, dag_id: str, session: Session = NEW_SESSION) 
-> SerializedDagModel
         """
         return session.scalar(cls.latest_item_select_object(dag_id))
 
+    @classmethod
+    def _process_dag_dependencies_query(
+        cls, query, load_json: Callable[[bytes | str], list] | None
+    ) -> Iterator[tuple[str, list]]:
+        """Process query results for DAG dependencies, yielding (dag_id, 
dependencies) tuples."""
+        for dag_id, deps_data in query:
+            if load_json is not None:
+                yield (dag_id, load_json(deps_data))
+            else:
+                yield (str(dag_id), deps_data if deps_data else [])

Review Comment:
   Since `load_json` doesn't change in the loop, we don't have to check it in 
each iteration. We can switch the `if` and the `for`:
   
   ```python
   id_: str
   deps: list
   if load_json is not None:
       for dag_id, deps_data in query:
           id_ = dag_id
           deps = load_json(deps_data)
           yield (dag_id, deps)
   else:
       for dag_id, deps_data in query:
           id_ = str(dag_id)
           deps = deps_data or []
           yield (dag_id, deps)



-- 
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