Skip to content

Prek hook to detect drift in RuntimeTaskInstance and its protocol - #67223

Closed
amoghrajesh wants to merge 1 commit into
apache:mainfrom
amoghrajesh:worktree-prek-runtime-ti-protocol-sync
Closed

Prek hook to detect drift in RuntimeTaskInstance and its protocol#67223
amoghrajesh wants to merge 1 commit into
apache:mainfrom
amoghrajesh:worktree-prek-runtime-ti-protocol-sync

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

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

related to: #67216

RuntimeTaskInstanceProtocoland RuntimeTaskInstance have drifted in the past most recently fixed in #67216. This PR adds a prek hook to catch that automatically.

The hook parses both files via AST and fails if:

  • A public member declared in RuntimeTaskInstance is absent from the Protocol
  • A shared method has mismatched positional parameter names (the specific bug Sync RuntimeTaskInstanceProtocol with RuntimeTaskInstance #67216 fixed)
  • Members intentionally absent from the Protocol (e.g. bundle_instance, sentry_integration) are covered by an explicit IMPLEMENTATION_ONLY allow list with comments. The hook triggers on changes to either file.

  • 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.

@amoghrajesh

Copy link
Copy Markdown
Contributor Author

Will get back to this when I have b/w next week

@amoghrajesh
amoghrajesh marked this pull request as draft May 27, 2026 04:27
if _is_property(item):
members.properties.add(name)
else:
params = [a.arg for a in item.args.args if a.arg != "self"]

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.

This also needs to check posonlyargs. We don’t currently use the syntax anywhere in the main code base, but this could change in the future.

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.

Also should we consider classmethods too (cls)?

Comment on lines +74 to +80
def _is_property(node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool:
for dec in node.decorator_list:
if isinstance(dec, ast.Name) and dec.id == "property":
return True
if isinstance(dec, ast.Attribute) and dec.attr == "property":
return True
return False

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.

Do we need to consider cached_property too?

tree = ast.parse(source_path.read_text(), filename=str(source_path))
members = ClassMembers()

for node in ast.walk(tree):

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.

From what I can tell, this loop intends to process only top-level members (the break on line 108). If so, this can avoid ast.walk and use tree.body directly instead.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 14, 2026
@github-actions github-actions Bot closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:task-sdk stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants