Repository navigation
patchedast cleanup and refactoring - #896
Merged
Merged
Conversation
Now that all supported python version supports ast end_col_offset, we can rely on the end node address instead of regex to find the node region. This is much simpler and way less error prone than using regex.
Use consume_node() instead of regex pattern matching.
These node handlers were used in very old python version that was no longer supported. The relevant handler are now implemented by _PatchingASTWalker._Constant().
In current version of python this is now handled by _Subscript()
Constant nodes are leaf nodes that doesn't have any children, they're simply consumed and does not need further recursive processing.
This simplifies the logic of dealing with comma in the withitems, we no longer need the with_or_comma_context_manager sentinel and special handling.
Now that all the consume_string, consume_number, consume_with_or_comma_context_manager, and consume_empty_tuple have been removed, this method is no longer needed.
These has long been unused.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #896 +/- ##
=======================================
Coverage 95.34% 95.34%
=======================================
Files 134 134
Lines 26819 26762 -57
=======================================
- Hits 25570 25516 -54
+ Misses 1249 1246 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
Simplified a bunch of code in patchedast, mostly to take advantage of the availability of
end_col_offsetfrom theastparser, we no longer need many of these overly complicated ways to figure out the node regions.Checklist (delete if not relevant):