Skip to content

Make the libcst (CST) backend usable for recipes - #270

Merged
FrancescoPezzella merged 14 commits into
mainfrom
libcst-replace-framework
Nov 5, 2026
Merged

FrancescoPezzella merged 14 commits into
mainfrom
libcst-replace-framework

Conversation

@FrancescoPezzella

@FrancescoPezzella FrancescoPezzella commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes PythonCstNode (the libcst backend) usable by recipes, as a step towards ADR 11 (libcst for Python, still a Proposal) and the "don't reinvent the wheel" point in #104 and #14. The RST backend stays the default, so existing recipes behave the same.

The scope is deliberately minimal: only what is needed in #202 to not duplicate a lot of code, and to be able to actually use what is in the framework

Relates to #14 #104 #153 #188 #189 #261 #265 #266
Does not fully resolve any direct issue

@FrancescoPezzella FrancescoPezzella self-assigned this Oct 9, 2026
@FrancescoPezzella FrancescoPezzella added the python language Issues related to analysis and transformation of the Python language label Oct 9, 2026
@FrancescoPezzella

Copy link
Copy Markdown
Collaborator Author

@FrancescoPezzella
FrancescoPezzella changed the base branch from main to astnode-change-minor October 12, 2026 09:39
@FrancescoPezzella FrancescoPezzella changed the title libcst tbd Make the libcst (CST) backend usable for recipes Oct 12, 2026
@FrancescoPezzella
FrancescoPezzella marked this pull request as ready for review October 12, 2026 12:19
@FrancescoPezzella FrancescoPezzella added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 12, 2026
@FrancescoPezzella
FrancescoPezzella removed this pull request from stack #277 October 16, 2026 11:58
@FrancescoPezzella
FrancescoPezzella removed this pull request from stack #295 October 26, 2026 12:13
Base automatically changed from astnode-change-minor to main October 29, 2026 09:53
@FrancescoPezzella
FrancescoPezzella force-pushed the libcst-replace-framework branch 2 times, most recently from 1956d5c to 0a7d899 Compare October 29, 2026 12:55

@pjljvandelaar pjljvandelaar left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.
Some minor discussions points / improvements open.
Once fixed, I will approve and you can merge.

Comment thread test/python/ast/test_python_cst_node.py Resolved

@pjljvandelaar pjljvandelaar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor questions.

I will approve once answered.

@FrancescoPezzella
FrancescoPezzella removed this pull request from stack #305 November 3, 2026 20:47
@FrancescoPezzella
FrancescoPezzella force-pushed the libcst-replace-framework branch 2 times, most recently from 78120d0 to e8b320f Compare November 4, 2026 08:55
…pansThe three CST xfails in test_offset_encoding now pass; spans match the RST backend (decorators included, trailing newline excluded).
references/referenced_by link each use to its definition (string annotations included), so MatchFinder's reference matching now works on the CST backend.
PythonRefactoring is generic over the node class (RST by default), and body returns the module's top-level statements on both backends.
libcst only links a use to definitions above it; annotations and type hints are evaluated lazily, so they now count too.
…8 bytes only, and state that the CST adapter's offsets count bytes of the filesystem encoding until that migration.
…, and build nodes of the subclass in its constructor and loaders so the annotation holds.
…e parsers, rewriter, text utilities and tests, with the explicit UTF-8 encoding in the Python loaders. Make Ci/Cd pass with Pyright fix.
… no assertion accesses an optional parent or sibling.
@FrancescoPezzella

Copy link
Copy Markdown
Collaborator Author

briefly discussed during meeting, will merge

@FrancescoPezzella
FrancescoPezzella enabled stacked auto-merge November 5, 2026 09:47
@FrancescoPezzella
FrancescoPezzella merged commit 47c3d7a into main Nov 5, 2026
10 checks passed
@FrancescoPezzella
FrancescoPezzella deleted the libcst-replace-framework branch November 5, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request python language Issues related to analysis and transformation of the Python language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants