Prek hook to detect drift in RuntimeTaskInstance and its protocol - #67223
Prek hook to detect drift in RuntimeTaskInstance and its protocol#67223amoghrajesh wants to merge 1 commit into
Conversation
|
Will get back to this when I have b/w next week |
| if _is_property(item): | ||
| members.properties.add(name) | ||
| else: | ||
| params = [a.arg for a in item.args.args if a.arg != "self"] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Also should we consider classmethods too (cls)?
| 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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
|
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. |
Was generative AI tooling used to co-author this PR?
related to: #67216
RuntimeTaskInstanceProtocolandRuntimeTaskInstancehave 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:
RuntimeTaskInstanceProtocolwithRuntimeTaskInstance#67216 fixed)IMPLEMENTATION_ONLYallow list with comments. The hook triggers on changes to either file.{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.