potiuk commented on code in PR #28900:
URL: https://github.com/apache/airflow/pull/28900#discussion_r1333867561


##########
airflow/models/taskinstance.py:
##########
@@ -190,23 +192,24 @@ def set_current_context(context: Context) -> 
Generator[Context, None, None]:
             )
 
 
-def _stop_remaining_tasks(*, self, session: Session):
+def _stop_remaining_tasks(*, task_instance: TaskInstance | 
TaskInstancePydantic, session: Session):
     """
     Stop non-teardown tasks in dag.
 
     :meta private:
     """
-    tis = self.dag_run.get_task_instances(session=session)
+    assert task_instance.dag_run is not None

Review Comment:
   We only use asserts in in special circumstances (TYPE_CHECKING for example) 
- I suggest to change it to 
   
   ```
   if not task_instance_.dag_run:
      raise ValueError("task_instance must have dag_run set")
   
   ```
   
   or similar.



-- 
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-unsubscr...@airflow.apache.org

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

Reply via email to