Add formatter support for call and class definition Arguments#6274
Merged
charliermarsh merged 1 commit intomainfrom Aug 2, 2023
Merged
Add formatter support for call and class definition Arguments#6274charliermarsh merged 1 commit intomainfrom
Arguments#6274charliermarsh merged 1 commit intomainfrom
Conversation
charliermarsh
commented
Aug 2, 2023
| self.opening, | ||
| // end-of-line comments | ||
| dangling_comments(&self.comments[..end_of_line_split]), | ||
| trailing_comments(&self.comments[..end_of_line_split]), |
Member
Author
There was a problem hiding this comment.
We don't want these to break, IIUC.
charliermarsh
commented
Aug 2, 2023
| class_definition: &'a StmtClassDef, | ||
| } | ||
|
|
||
| impl Format<PyFormatContext<'_>> for FormatInheritanceClause<'_> { |
Member
Author
There was a problem hiding this comment.
We get all of this for free now, I think.
charliermarsh
commented
Aug 2, 2023
| #[derive(Default)] | ||
| pub struct FormatArguments; | ||
|
|
||
| impl FormatNodeRule<Arguments> for FormatArguments { |
Member
Author
There was a problem hiding this comment.
This is largely moved from expr_call.
b5af1c1 to
4d34062
Compare
zanieb
approved these changes
Aug 2, 2023
Member
Author
|
Looking into ecosystem failure. |
Member
Author
|
(Need to fix a few things.) |
Contributor
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
4d34062 to
1315f7c
Compare
1315f7c to
e277615
Compare
MichaReiser
reviewed
Aug 3, 2023
MichaReiser
reviewed
Aug 3, 2023
MichaReiser
reviewed
Aug 3, 2023
MichaReiser
reviewed
Aug 3, 2023
MichaReiser
reviewed
Aug 3, 2023
This was referenced Aug 3, 2023
charliermarsh
added a commit
that referenced
this pull request
Aug 3, 2023
## Summary Based on the confusion here: #6274 (comment). I looked into moving this logic into `placement.rs`, but I think it's trickier than it may appear.
charliermarsh
added a commit
that referenced
this pull request
Aug 3, 2023
Micha suggested this in #6274 (comment), and it allows us to unify the implementations for arguments and type params.
charliermarsh
added a commit
that referenced
this pull request
Aug 4, 2023
Based on feedback here: #6274 (comment).
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 leverages the
ArgumentsAST node introduced in #6259 in the formatter, which ensures that we correctly handle trailing comments in calls, like:(Previously, this was treated as a leading comment on
pass.)This also allows us to unify the argument handling across calls and class definitions.
Test Plan
A bunch of new fixture tests, plus improved Black compatibility.