Suite formatting and JoinNodesBuilder#4805
Merged
MichaReiser merged 3 commits intomainfrom Jun 2, 2023
Merged
Conversation
This was referenced Jun 2, 2023
Merged
Merged
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
Contributor
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
0dd25f8 to
57a621b
Compare
6717291 to
cfaf878
Compare
konstin
approved these changes
Jun 2, 2023
| use rustpython_parser::ast::Ranged; | ||
|
|
||
| /// Provides Python specific extensions to [`Formatter`]. | ||
| pub(crate) trait PyFormatterExtensions<'buf, 'context> { |
Member
There was a problem hiding this comment.
Is this meant as a general purpose "attach your utils crate" or as specific for the node builder?
Member
Author
There was a problem hiding this comment.
At rome, we only really had builder extensions but it might be useful to add some more (and move the trait?). For example, we could add a contents() or comments methods so that we don't need to always go through the context.
Do you want me to move the trait to the lib.rs?
Member
Author
There was a problem hiding this comment.
I'll merge this to reduce the stack size. I can follow up with another PR if you want me to move it.
This was referenced Jun 2, 2023
f5521f0 to
d113ea6
Compare
Merged
d113ea6 to
530cb36
Compare
konstin
pushed a commit
that referenced
this pull request
Jun 13, 2023
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.

Summary
This PR adds a new
JoinNodesBuilderthat simplifies writing a sequence of nodes while respecting the empty lines between nodes.Or if you always want to use the node's format implementation, then use
This PR further adds a
Formatimplementation forVec<Suite>that adds the right amount of empty lines around classes and functions, and keeps empty lines for all other statements.Test Plan
I added a few test plans. I intentionally didn't use the new formatting yet.