Skip to content

Widen type hint for DagRun.get_task_instances / fetch_task_instances state parameter#67880

Merged
shahar1 merged 1 commit into
apache:mainfrom
tysoncung:fix/dagrun-type-hint-67653
Jun 2, 2026
Merged

Widen type hint for DagRun.get_task_instances / fetch_task_instances state parameter#67880
shahar1 merged 1 commit into
apache:mainfrom
tysoncung:fix/dagrun-type-hint-67653

Conversation

@tysoncung
Copy link
Copy Markdown
Contributor

Fixes #67653

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.

Fix: Widen the annotation to TaskInstanceState | Iterable[TaskInstanceState | None] | None on both methods to match the actual runtime behaviour.

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 apache#67653
@tysoncung tysoncung requested review from XD-DENG and ashb as code owners June 1, 2026 23:45
@shahar1 shahar1 added the backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch label Jun 2, 2026
@shahar1 shahar1 changed the title fix: widen type hint for DagRun.get_task_instances / fetch_task_instances state parameter Widen type hint for DagRun.get_task_instances / fetch_task_instances state parameter Jun 2, 2026
@shahar1 shahar1 merged commit fb56cef into apache:main Jun 2, 2026
81 checks passed
@github-actions github-actions Bot added this to the Airflow 3.2.3 milestone Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.2.3 based on: backport label targeting v3-2-test
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Backport failed to create: v3-2-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test Commit Link

You can attempt to backport this manually by running:

cherry_picker fb56cef v3-2-test

This should apply the commit to the v3-2-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DagRun.get_task_instances / fetch_task_instances accept a single TaskInstanceState at runtime, but the type hint only allows an Iterable

2 participants