Skip to content

Commit

Permalink
Format continue statement (#5165)
Browse files Browse the repository at this point in the history
<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

Format `continue` statement.

## Test Plan

`continue` is used already in some tests, but if a new test is needed I
could add it.

---------

Co-authored-by: konstin <konstin@mailbox.org>
  • Loading branch information
cnpryer and konstin authored Jun 18, 2023
1 parent 5c416e4 commit 195b36c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ instruction()#comment with bad spacing
pass
# no newline before or after
short = [
@@ -91,75 +88,29 @@
@@ -91,48 +88,14 @@
]
# no newline after
Expand Down Expand Up @@ -356,10 +356,8 @@ instruction()#comment with bad spacing
+ lcomp3 = [i for i in []]
while True:
if False:
- continue
+ NOT_YET_IMPLEMENTED_StmtContinue
# and round and round we go
continue
@@ -141,25 +104,13 @@
# and round and round we go
# let's return
Expand Down Expand Up @@ -502,7 +500,7 @@ def inline_comments_in_brackets_ruin_everything():
lcomp3 = [i for i in []]
while True:
if False:
NOT_YET_IMPLEMENTED_StmtContinue
continue
# and round and round we go
# and round and round we go
Expand Down
9 changes: 5 additions & 4 deletions crates/ruff_python_formatter/src/statement/stmt_continue.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
use ruff_formatter::{write, Buffer, FormatResult};
use crate::{FormatNodeRule, PyFormatter};
use ruff_formatter::prelude::text;
use ruff_formatter::{Format, FormatResult};
use rustpython_parser::ast::StmtContinue;

#[derive(Default)]
pub struct FormatStmtContinue;

impl FormatNodeRule<StmtContinue> for FormatStmtContinue {
fn fmt_fields(&self, item: &StmtContinue, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [not_yet_implemented(item)])
fn fmt_fields(&self, _item: &StmtContinue, f: &mut PyFormatter) -> FormatResult<()> {
text("continue").fmt(f)
}
}

0 comments on commit 195b36c

Please sign in to comment.