From 195b36c429d12bad19fe5931bb24aa31a3d6c439 Mon Sep 17 00:00:00 2001 From: Chris Pryer <14341145+cnpryer@users.noreply.github.com> Date: Sun, 18 Jun 2023 07:25:59 -0400 Subject: [PATCH] Format `continue` statement (#5165) ## 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 --- ...hon_formatter__tests__black_test__comments2_py.snap | 10 ++++------ .../src/statement/stmt_continue.rs | 9 +++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/ruff_python_formatter/src/snapshots/ruff_python_formatter__tests__black_test__comments2_py.snap b/crates/ruff_python_formatter/src/snapshots/ruff_python_formatter__tests__black_test__comments2_py.snap index 90b926319600d..7869c241a8dfb 100644 --- a/crates/ruff_python_formatter/src/snapshots/ruff_python_formatter__tests__black_test__comments2_py.snap +++ b/crates/ruff_python_formatter/src/snapshots/ruff_python_formatter__tests__black_test__comments2_py.snap @@ -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 @@ -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 @@ -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 diff --git a/crates/ruff_python_formatter/src/statement/stmt_continue.rs b/crates/ruff_python_formatter/src/statement/stmt_continue.rs index b216ba7c46715..d6403fd1bf78f 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_continue.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_continue.rs @@ -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 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) } }