-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support fmt: skip
for simple-statements and decorators
#6561
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
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
PR Check ResultsBenchmarkLinux
Windows
|
12f9bbc
to
bdab1c2
Compare
05c1442
to
3eb2b08
Compare
bdab1c2
to
df98068
Compare
3eb2b08
to
8731120
Compare
8731120
to
5f5873c
Compare
f40f7c9
to
5bc64b5
Compare
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()) { |
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 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
@@ -902,7 +902,7 @@ fn handle_leading_class_with_decorators_comment<'a>( | |||
comment: DecoratedComment<'a>, | |||
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() { |
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.
End-of-line comments are already correctly associated, I'm guessing, since they're associated with the preceding rather than the following node?
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.
Yes. The default placement correctly associates them with the decorator (preceding) node.
142d47b
to
e2de436
Compare
Summary
This PR implements support for trailing
fmt: skip
andfmt: off
comments on statement and decorator level.This PR does not yet implement
fmt: skip
support at the end of a case header, e.g. at the end of anif
statementTest Plan
Matching black tests, added new tests