-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suite formatting and JoinNodesBuilder
#4805
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
0dd25f8
to
57a621b
Compare
6717291
to
cfaf878
Compare
use rustpython_parser::ast::Ranged; | ||
|
||
/// Provides Python specific extensions to [`Formatter`]. | ||
pub(crate) trait PyFormatterExtensions<'buf, 'context> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant as a general purpose "attach your utils crate" or as specific for the node builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this to reduce the stack size. I can follow up with another PR if you want me to move it.
f5521f0
to
d113ea6
Compare
d113ea6
to
530cb36
Compare
Summary
This PR adds a new
JoinNodesBuilder
that 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
Format
implementation 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.