Lohith625 commented on code in PR #56924:
URL: https://github.com/apache/airflow/pull/56924#discussion_r2610904233


##########
providers/standard/src/airflow/providers/standard/operators/trigger_dagrun.py:
##########
@@ -29,23 +30,30 @@
 
 from airflow.api.common.trigger_dag import trigger_dag
 from airflow.configuration import conf
-from airflow.exceptions import DagNotFound, DagRunAlreadyExists
-from airflow.models.dag import DagModel
-from airflow.models.dagrun import DagRun
-from airflow.models.serialized_dag import SerializedDagModel
-from airflow.providers.common.compat.sdk import (
+from airflow.exceptions import (
     AirflowException,
     AirflowSkipException,
-    BaseOperatorLink,
-    XCom,
-    timezone,
+    DagNotFound,
+    DagRunAlreadyExists,
 )
+from airflow.models.dag import DagModel
+from airflow.models.dagrun import DagRun
+from airflow.models.serialized_dag import SerializedDagModel
+from airflow.providers.common.compat.sdk import BaseOperatorLink, XCom, 
timezone
 from airflow.providers.standard.triggers.external_task import DagStateTrigger
 from airflow.providers.standard.utils.openlineage import 
safe_inject_openlineage_properties_into_dagrun_conf
 from airflow.providers.standard.version_compat import AIRFLOW_V_3_0_PLUS, 
BaseOperator
 from airflow.utils.state import DagRunState
 from airflow.utils.types import DagRunType
 
+try:
+    from airflow.utils.types import DagRunTriggeredByType
+except Exception:
+    if TYPE_CHECKING:
+        from airflow.utils.types import DagRunTriggeredByType  # type: 
ignore[no-redef]
+    else:
+        DagRunTriggeredByType = None

Review Comment:
   Thanks for the clarification!
   You're right — the extra TYPE_CHECKING branch inside the try-except was 
redundant.
   
   I’ve now simplified the block exactly as suggested:
   
   ```
   try:
       from airflow.utils.types import DagRunTriggeredByType
   except Exception:
       DagRunTriggeredByType = None  # type: 
ignore[assignment,misc,unused-ignore]
   
   ```
   
   This keeps the code cleaner and resolves the mypy issue as well.
   Changes pushed — please let me know if further adjustment is needed!



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