Mark expression_statement as a supertype#317
Merged
amaanq merged 3 commits intotree-sitter:masterfrom Sep 15, 2025
Merged
Conversation
amaanq
reviewed
Sep 15, 2025
5f3c949 to
b2dd704
Compare
b2dd704 to
a0cf8eb
Compare
gentoo-crate-dist-bot
pushed a commit
to gentoo-crate-dist/mergiraf
that referenced
this pull request
Sep 18, 2025
… (#590) Closes #589. I am not very happy with the overall approach, but it feels like it's the best I can do. Ideally, the bundling of the comments should be done in the grammar, similarly to what we do in Rust, since the attachment is done by Python itself, regardless of the amount of whitespace surrounding it. But I haven't been able to update the grammar accordingly so far. We could also decide to define the additional comments via a tree-sitter query, but as things stand it would still not remove the need to fork the grammar because the `assignment` nodes are wrapped inside an `expression_statement` node, making it impossible to define the commutative children groups as things stand (except if we also migrate those to support TS queries…) That being said, there are [good signs that the tree-sitter-python maintainer will accept a move to hide those `expression_statement` nodes](tree-sitter/tree-sitter-python#317) in the upstream grammar. When that gets published, we could then be able to switch back to upstream, assuming we change the `comment_nodes` to use a tree-sitter query instead. But that also has downsides, since that's going to add another query to execute at the beginning of the parsing, complicating the `AstNode` construction a bit further. In the interest of meeting Stainless' needs, I think it would still be good to ship this (or some variant of it…) Reviewed-on: https://codeberg.org/mergiraf/mergiraf/pulls/590 Reviewed-by: Ada Alakbarova <ada4a@noreply.codeberg.org> Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu> Co-committed-by: Antonin Delpeuch <antonin@delpeuch.eu>
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.
As suggested by @amaanq in #312