This is an automated email from the ASF dual-hosted git repository.
shahar1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new fb56cef48c8 Widen type hint for DagRun.get_task_instances state
parameter (#67880)
fb56cef48c8 is described below
commit fb56cef48c84815f12010a90eebf21a30fae3e50
Author: Tyson Cung <[email protected]>
AuthorDate: Wed Jun 3 03:27:12 2026 +0800
Widen type hint for DagRun.get_task_instances state parameter (#67880)
The state parameter on DagRun.get_task_instances and
DagRun.fetch_task_instances was annotated as
Iterable[TaskInstanceState | None] | None, but the runtime
handles a single TaskInstanceState value via an isinstance(state, str)
short-circuit. Since TaskInstanceState(str, Enum) inherits from str,
calling with state=TaskInstanceState.FAILED works at runtime but
mypy/pyright flags it.
Widen the annotation to TaskInstanceState | Iterable[TaskInstanceState |
None] | None
to match the actual runtime behaviour.
Fixes #67653
---
airflow-core/src/airflow/models/dagrun.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/airflow-core/src/airflow/models/dagrun.py
b/airflow-core/src/airflow/models/dagrun.py
index 25f6397c074..36ef372e39a 100644
--- a/airflow-core/src/airflow/models/dagrun.py
+++ b/airflow-core/src/airflow/models/dagrun.py
@@ -836,7 +836,7 @@ class DagRun(Base, LoggingMixin):
dag_id: str | None = None,
run_id: str | None = None,
task_ids: list[str] | None = None,
- state: Iterable[TaskInstanceState | None] | None = None,
+ state: TaskInstanceState | Iterable[TaskInstanceState | None] | None =
None,
*,
session: Session = NEW_SESSION,
) -> list[TI]:
@@ -917,7 +917,7 @@ class DagRun(Base, LoggingMixin):
@provide_session
def get_task_instances(
self,
- state: Iterable[TaskInstanceState | None] | None = None,
+ state: TaskInstanceState | Iterable[TaskInstanceState | None] | None =
None,
*,
session: Session = NEW_SESSION,
) -> list[TI]: