Skip to content

Add deadline and callback exports to airflow.sdk type stub - #70578

Closed
rapsealk wants to merge 3 commits into
apache:mainfrom
rapsealk:fix/sdk-stub-deadline-exports
Closed

rapsealk wants to merge 3 commits into
apache:mainfrom
rapsealk:fix/sdk-stub-deadline-exports

Conversation

@rapsealk

@rapsealk rapsealk commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

AsyncCallback, SyncCallback, DeadlineAlert and DeadlineReference are importable from airflow.sdk at runtime via its lazy import map, but task-sdk/src/airflow/sdk/__init__.pyi had no entries for them. The Deadline Alerts documentation tells users to write from airflow.sdk import DeadlineAlert, which then fails a type check:

error: Module "airflow.sdk" has no attribute "DeadlineAlert"  [attr-defined]

This adds the four names to the stub's imports and __all__. SyncCallback is included for stub/runtime parity — it is a public class in airflow.sdk.definitions.callback alongside AsyncCallback, and leaving it out would just reproduce the same gap for the next user.

Split out of #66269 at review request — that PR mixed this fix with an example Dag and a serialization fix.

Verification

  • prek run mypy-task-sdk --all-files passes.
  • With this change applied, a Dag using from airflow.sdk import DAG, AsyncCallback, DeadlineAlert, DeadlineReference, task typechecks clean under mypy-airflow-core; without it, mypy reports three attr-defined errors.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines


Important

🛠️ Maintainer triage note for @rapsealk · by @potiuk · 2026-08-13 12:55 UTC

Helpful heads-up from the maintainers — please address before this PR can be reviewed:

  • ❌ Pre-commit / static checks. See docs.

Full list of what we check: Pull Request quality criteria.

The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.

Automated triage — may be imperfect; a maintainer takes the next look.

AsyncCallback, SyncCallback, DeadlineAlert and DeadlineReference are
importable from airflow.sdk at runtime via its lazy import map, but the
type stub had no entries for them. The Deadline Alerts documentation
tells users to write `from airflow.sdk import DeadlineAlert`, which then
fails a type check with attr-defined.
@rapsealk rapsealk changed the title fix: Add deadline and callback exports to airflow.sdk type stub Add deadline and callback exports to airflow.sdk type stub Jul 28, 2026
@rapsealk
rapsealk force-pushed the fix/sdk-stub-deadline-exports branch from 27a79a2 to 1d299d8 Compare August 17, 2026 08:12
@ferruzzi

ferruzzi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Closing this asit appears this has already landed. To be clear, your change was right, we just mixed up the merge order.

This was split out of #66269 at review request, but #66269 then merged on 29 August still carrying the same six lines in task-sdk/src/airflow/sdk/__init__.pyi, so the split never got reflected in the parent. I compared the two changesets line by line and they are identical. All six are on main today, each exactly once:

  • from airflow.sdk.definitions.callback import AsyncCallback, SyncCallback
  • from airflow.sdk.definitions.deadline import DeadlineAlert, DeadlineReference
  • "AsyncCallback", "SyncCallback", "DeadlineAlert" and "DeadlineReference" in __all__

So the gap you reported is closed, including SyncCallback which you argued for on stub/runtime parity grounds, and the fix is credited to you via #66269 either way.

Thanks for doing the split, and apologies that it ended up unused. If you (or anyone else) sees this and thinks it's a mistake, please let me know.

@ferruzzi ferruzzi closed this Sep 8, 2026
@rapsealk
rapsealk deleted the fix/sdk-stub-deadline-exports branch September 9, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants