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


##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -1898,22 +1897,23 @@ def get_template_context(
         :param session: SQLAlchemy ORM Session
         :param ignore_param_exceptions: flag to suppress value exceptions 
while initializing the ParamsDict
         """
-        if TYPE_CHECKING:
-            assert self.task
-            assert isinstance(self.task.dag, SchedulerDAG)
-
         # Do not use provide_session here -- it expunges everything on exit!
         if not session:
             session = settings.Session()
 
+        if TYPE_CHECKING:
+            assert session
+            assert isinstance(self.task, (BaseOperator, MappedOperator))

Review Comment:
   Mypy (1.9 where we’re on) has some bugs regarding this. 
https://github.com/python/mypy/pull/17371
   
   This will need to wait for https://github.com/apache/airflow/pull/52997



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