We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9664474 commit c50d6c3Copy full SHA for c50d6c3
crates/ruff_python_formatter/src/comments/placement.rs
@@ -569,6 +569,15 @@ fn handle_own_line_comment_between_statements<'a>(
569
// y = 2
570
// ```
571
if max_empty_lines(&source[TextRange::new(comment.end(), following.start())]) == 0 {
572
+ for token in SimpleTokenizer::new(source, TextRange::new(comment.end(), following.start()))
573
+ {
574
+ match token.kind() {
575
+ SimpleTokenKind::Else | SimpleTokenKind::Finally => {
576
+ return CommentPlacement::dangling(comment.enclosing_node(), comment);
577
+ }
578
+ _ => {}
579
580
581
CommentPlacement::leading(following, comment)
582
} else {
583
CommentPlacement::trailing(preceding, comment)
0 commit comments