Improve precision of the remove_task_decorator function#34509
Closed
SamWheating wants to merge 2 commits intoapache:mainfrom
Closed
Improve precision of the remove_task_decorator function#34509SamWheating wants to merge 2 commits intoapache:mainfrom
SamWheating wants to merge 2 commits intoapache:mainfrom
Conversation
e0084e5 to
0a45403
Compare
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #34154
The
remove_task_decoratorcan incorrectly truncate function bodies if there are specific comments in the function body present, which is a rare edge case but can lead to really misleading behaviour where only a part of the intended code is executed.I think that the correct way to do code manipulation like this would be to lean on the
astlibrary, but the ability to go from ast back to code was only added in python 3.9 with theast.unparse()function.Anyways, this PR is an attempt to improve the accuracy of this method. While I don't think that this is perfect, it at least solves the issue for the cases in the linked issue with the following changes:
Any suggestions welcome.
If you want to discuss this IRL, come find me at Airflow Summit :)