Skip to content

Conversation

wetneb
Copy link
Contributor

@wetneb wetneb commented Sep 13, 2025

As suggested by @amaanq in #312

@wetneb wetneb force-pushed the expression_statement_supertype branch from 5f3c949 to b2dd704 Compare September 15, 2025 10:38
@wetneb wetneb force-pushed the expression_statement_supertype branch from b2dd704 to a0cf8eb Compare September 15, 2025 20:03
Copy link
Member

@amaanq amaanq left a comment

Choose a reason for hiding this comment

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

thank you!

@amaanq amaanq merged commit 26855ea into tree-sitter:master Sep 15, 2025
4 checks passed
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 <[email protected]>
Co-authored-by: Antonin Delpeuch <[email protected]>
Co-committed-by: Antonin Delpeuch <[email protected]>
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.

2 participants