uranusjr commented on code in PR #56924:
URL: https://github.com/apache/airflow/pull/56924#discussion_r2609280788
##########
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:
You don’t need to do this, type-checking imports ignore try-except.
```suggestion
try:
from airflow.utils.types import DagRunTriggeredByType
except Exception:
DagRunTriggeredByType = None # type: ignore[i-dont-remember-which-code]
```
--
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]