uranusjr commented on a change in pull request #18471:
URL: https://github.com/apache/airflow/pull/18471#discussion_r715913452



##########
File path: airflow/operators/python.py
##########
@@ -178,6 +178,16 @@ class BranchPythonOperator(PythonOperator, SkipMixin):
 
     def execute(self, context: Dict):
         branch = super().execute(context)
+        # TODO: The logic should be moved to SkipMixin to be available to all 
branch operators.
+        if not isinstance(branch, (str, List)):
+            raise AirflowException("Branch callable must return either a task 
ID or a list of IDs")
+        branches = {branch}

Review comment:
       ```suggestion
           if isinstance(branch, str):
               branches = {branch}
           elif isinstance(branch, list):
               branches = set(branch)
           else:
               raise AirflowException("Branch callable must return either a 
task ID or a list of IDs")
   ```
   
   Otherwise if `branch` is a list (e.g. `["task_a", "task_b"]`), `branches` 
would become a set containing one list of strings (`{["task_a", "task_b"]}`). 
We need a set of strings (`{"task_a", "task_b"}`).




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