Skip to content

patchedast cleanup and refactoring - #896

Merged
lieryan merged 12 commits into
masterfrom
lieryan-patchedast-cleanup
Oct 7, 2026
Merged

lieryan merged 12 commits into
masterfrom
lieryan-patchedast-cleanup

Conversation

@lieryan

@lieryan lieryan commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

Simplified a bunch of code in patchedast, mostly to take advantage of the availability of end_col_offset from the ast parser, we no longer need many of these overly complicated ways to figure out the node regions.

Checklist (delete if not relevant):

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated CHANGELOG.md

lieryan added 10 commits October 8, 2026 03:43
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

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.34%. Comparing base (e4e9908) to head (19dc45e).
⚠️ Report is 13 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lieryan
lieryan enabled auto-merge October 7, 2026 18:19
@lieryan
lieryan merged commit 7a3a9a2 into master Oct 7, 2026
45 checks passed
@lieryan
lieryan deleted the lieryan-patchedast-cleanup branch October 7, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant