Skip to content

Convert check-sdk-imports to capture occurences than files - #71212

Merged
amoghrajesh merged 3 commits into
apache:mainfrom
amoghrajesh:strengthen-prek-sdk-imports
Aug 11, 2026
Merged

Convert check-sdk-imports to capture occurences than files#71212
amoghrajesh merged 3 commits into
apache:mainfrom
amoghrajesh:strengthen-prek-sdk-imports

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

The hook was meant to stop airflow-core from gaining new runtime dependencies on the task SDK, but it worked by excluding whole files that already had an import when the check was added. That made it blind to new imports added later to any of those files - which is exactly what happened in #70370, where a new airflow.sdk import landed
in models/taskinstance.py unnoticed because the file was already on the exclude list for an older, unrelated import.

Track an allowed import count per file instead (same pattern as check_new_airflow_exception_usage.py), so existing file can't quietly gain more without either a # noqa: SDK001 or a deliberate allowlist regeneration.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yeah, it makes sense to follow the know_....txt convention.

Comment thread generated/known_sdk_imports_in_core.txt Outdated

@ferruzzi ferruzzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two thoughts, non-blocking. Thanks for taking this on.

Comment thread scripts/ci/prek/check_sdk_imports_in_core.py Outdated
Comment thread scripts/ci/prek/check_sdk_imports_in_core.py
Comment thread scripts/ci/prek/check_sdk_imports_in_core.py
Comment thread generated/known_sdk_imports_in_core.txt
@amoghrajesh
amoghrajesh merged commit d8cfc95 into apache:main Aug 11, 2026
69 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

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-3-test PR Link

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants