You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussein-awala (via GitHub)" <gi...@apache.org> on 2023/09/01 22:26:18 UTC

[GitHub] [airflow] hussein-awala commented on a diff in pull request #33988: Combine similar if logics in core

hussein-awala commented on code in PR #33988:
URL: https://github.com/apache/airflow/pull/33988#discussion_r1313593943


##########
airflow/models/baseoperator.py:
##########
@@ -1107,9 +1107,11 @@ def dag(self, dag: DAG | None):
 
         if self.__from_mapped:
             pass  # Don't add to DAG -- the mapped task takes the place.
-        elif self.task_id not in dag.task_dict:
-            dag.add_task(self)
-        elif self.task_id in dag.task_dict and dag.task_dict[self.task_id] is not self:
+        elif (
+            self.task_id not in dag.task_dict
+            or self.task_id in dag.task_dict
+            and dag.task_dict[self.task_id] is not self
+        ):

Review Comment:
   Indeed, the second suggestion should do the job.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org