feat(Python): Enable commutation of class attributes, with docstrings #590
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#590
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "589-python-docstrings-bundle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 anexpression_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 in the upstream grammar. When that gets published, we could then be able to switch back to upstream, assuming we change thecomment_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 theAstNode
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…)
589-python-docstrings-bundleto feat(Python): Enable commutation of class attributes, with docstrings@ -0,0 +3,4 @@
y = 2
z = 3
This example is crying for being spelt out without blank lines between arguments, but merging class attributes with docstrings requires us to still insert a blank line between the merged attributes, otherwise the docstrings end up being at equal distance between two consecutive attributes, which prevents them from being bundled correctly when re-parsing the merge result. This is calling for #373.
94dc6eea1a
to4368a54cd1