Support fmt: skip for simple-statements and decorators#6561
Merged
MichaReiser merged 1 commit intomainfrom Aug 17, 2023
Merged
Conversation
This was referenced Aug 14, 2023
Merged
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
Contributor
PR Check ResultsBenchmarkLinuxWindows |
12f9bbc to
bdab1c2
Compare
05c1442 to
3eb2b08
Compare
bdab1c2 to
df98068
Compare
3eb2b08 to
8731120
Compare
MichaReiser
commented
Aug 14, 2023
8731120 to
5f5873c
Compare
f40f7c9 to
5bc64b5
Compare
6 tasks
MichaReiser
commented
Aug 15, 2023
| self.fmt_node(node, f)?; | ||
| self.fmt_dangling_comments(node_comments.dangling, f)?; | ||
| trailing_comments(node_comments.trailing).fmt(f) | ||
| if self.is_suppressed(node_comments.trailing, f.context()) { |
Member
Author
There was a problem hiding this comment.
I considered handling the suppression in the FormatStmt so that it isn't necessary to override is_suppressed for all statements. However, it requires that FormatStmt resolves the trailing comments to test for a suppression comment, just for the FormatNodeRule to lookup the very same comments again.
5bc64b5 to
02330c4
Compare
fmt: skip on statement and decorator levelfmt: skip for simple-statements and decorator level
fmt: skip for simple-statements and decorator levelfmt: skip for simple-statements and decorators
02330c4 to
ef86a00
Compare
be450a6 to
072263c
Compare
ef86a00 to
8215d9d
Compare
247979d to
142d47b
Compare
charliermarsh
approved these changes
Aug 16, 2023
| class_def: &'a ast::StmtClassDef, | ||
| ) -> CommentPlacement<'a> { | ||
| if comment.start() < class_def.name.start() { | ||
| if comment.line_position().is_own_line() && comment.start() < class_def.name.start() { |
Member
There was a problem hiding this comment.
End-of-line comments are already correctly associated, I'm guessing, since they're associated with the preceding rather than the following node?
Member
Author
There was a problem hiding this comment.
Yes. The default placement correctly associates them with the decorator (preceding) node.
142d47b to
e2de436
Compare
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 implements support for trailing
fmt: skipandfmt: offcomments on statement and decorator level.This PR does not yet implement
fmt: skipsupport at the end of a case header, e.g. at the end of anifstatementTest Plan
Matching black tests, added new tests