mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Generate FormatRule definitions (#4724)
* Generate FormatRule definitions * Generate verbatim output * pub(crate) everything * clippy fix * Update crates/ruff_python_formatter/src/lib.rs Co-authored-by: Micha Reiser <micha@reiser.io> * Update crates/ruff_python_formatter/src/lib.rs Co-authored-by: Micha Reiser <micha@reiser.io> * stub out with Ok(()) again * Update crates/ruff_python_formatter/src/lib.rs Co-authored-by: Micha Reiser <micha@reiser.io> * PyFormatContext::{contents, locator} with `#[allow(unused)]` * Can't leak private type * remove commented code * Fix ruff errors * pub struct Format{node} due to rust rules --------- Co-authored-by: Julian LaNeve <lanevejulian@gmail.com> Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
b7294b48e7
commit
0945803427
88 changed files with 4136 additions and 46 deletions
27
crates/ruff_python_formatter/src/statement/mod.rs
Normal file
27
crates/ruff_python_formatter/src/statement/mod.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
pub(crate) mod stmt_ann_assign;
|
||||
pub(crate) mod stmt_assert;
|
||||
pub(crate) mod stmt_assign;
|
||||
pub(crate) mod stmt_async_for;
|
||||
pub(crate) mod stmt_async_function_def;
|
||||
pub(crate) mod stmt_async_with;
|
||||
pub(crate) mod stmt_aug_assign;
|
||||
pub(crate) mod stmt_break;
|
||||
pub(crate) mod stmt_class_def;
|
||||
pub(crate) mod stmt_continue;
|
||||
pub(crate) mod stmt_delete;
|
||||
pub(crate) mod stmt_expr;
|
||||
pub(crate) mod stmt_for;
|
||||
pub(crate) mod stmt_function_def;
|
||||
pub(crate) mod stmt_global;
|
||||
pub(crate) mod stmt_if;
|
||||
pub(crate) mod stmt_import;
|
||||
pub(crate) mod stmt_import_from;
|
||||
pub(crate) mod stmt_match;
|
||||
pub(crate) mod stmt_nonlocal;
|
||||
pub(crate) mod stmt_pass;
|
||||
pub(crate) mod stmt_raise;
|
||||
pub(crate) mod stmt_return;
|
||||
pub(crate) mod stmt_try;
|
||||
pub(crate) mod stmt_try_star;
|
||||
pub(crate) mod stmt_while;
|
||||
pub(crate) mod stmt_with;
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAnnAssign;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAnnAssign;
|
||||
|
||||
impl FormatNodeRule<StmtAnnAssign> for FormatStmtAnnAssign {
|
||||
fn fmt_fields(&self, _item: &StmtAnnAssign, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_assert.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_assert.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAssert;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAssert;
|
||||
|
||||
impl FormatNodeRule<StmtAssert> for FormatStmtAssert {
|
||||
fn fmt_fields(&self, _item: &StmtAssert, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_assign.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_assign.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAssign;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAssign;
|
||||
|
||||
impl FormatNodeRule<StmtAssign> for FormatStmtAssign {
|
||||
fn fmt_fields(&self, _item: &StmtAssign, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_async_for.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_async_for.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAsyncFor;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAsyncFor;
|
||||
|
||||
impl FormatNodeRule<StmtAsyncFor> for FormatStmtAsyncFor {
|
||||
fn fmt_fields(&self, _item: &StmtAsyncFor, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAsyncFunctionDef;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAsyncFunctionDef;
|
||||
|
||||
impl FormatNodeRule<StmtAsyncFunctionDef> for FormatStmtAsyncFunctionDef {
|
||||
fn fmt_fields(&self, _item: &StmtAsyncFunctionDef, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAsyncWith;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAsyncWith;
|
||||
|
||||
impl FormatNodeRule<StmtAsyncWith> for FormatStmtAsyncWith {
|
||||
fn fmt_fields(&self, _item: &StmtAsyncWith, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtAugAssign;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAugAssign;
|
||||
|
||||
impl FormatNodeRule<StmtAugAssign> for FormatStmtAugAssign {
|
||||
fn fmt_fields(&self, _item: &StmtAugAssign, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_break.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_break.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtBreak;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtBreak;
|
||||
|
||||
impl FormatNodeRule<StmtBreak> for FormatStmtBreak {
|
||||
fn fmt_fields(&self, _item: &StmtBreak, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_class_def.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_class_def.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtClassDef;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtClassDef;
|
||||
|
||||
impl FormatNodeRule<StmtClassDef> for FormatStmtClassDef {
|
||||
fn fmt_fields(&self, _item: &StmtClassDef, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_continue.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_continue.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::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<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_delete.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_delete.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtDelete;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtDelete;
|
||||
|
||||
impl FormatNodeRule<StmtDelete> for FormatStmtDelete {
|
||||
fn fmt_fields(&self, _item: &StmtDelete, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_expr.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_expr.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtExpr;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtExpr;
|
||||
|
||||
impl FormatNodeRule<StmtExpr> for FormatStmtExpr {
|
||||
fn fmt_fields(&self, _item: &StmtExpr, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_for.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_for.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtFor;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtFor;
|
||||
|
||||
impl FormatNodeRule<StmtFor> for FormatStmtFor {
|
||||
fn fmt_fields(&self, _item: &StmtFor, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtFunctionDef;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtFunctionDef;
|
||||
|
||||
impl FormatNodeRule<StmtFunctionDef> for FormatStmtFunctionDef {
|
||||
fn fmt_fields(&self, _item: &StmtFunctionDef, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_global.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_global.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtGlobal;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtGlobal;
|
||||
|
||||
impl FormatNodeRule<StmtGlobal> for FormatStmtGlobal {
|
||||
fn fmt_fields(&self, _item: &StmtGlobal, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_if.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_if.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtIf;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtIf;
|
||||
|
||||
impl FormatNodeRule<StmtIf> for FormatStmtIf {
|
||||
fn fmt_fields(&self, _item: &StmtIf, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_import.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_import.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtImport;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtImport;
|
||||
|
||||
impl FormatNodeRule<StmtImport> for FormatStmtImport {
|
||||
fn fmt_fields(&self, _item: &StmtImport, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtImportFrom;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtImportFrom;
|
||||
|
||||
impl FormatNodeRule<StmtImportFrom> for FormatStmtImportFrom {
|
||||
fn fmt_fields(&self, _item: &StmtImportFrom, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_match.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_match.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtMatch;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtMatch;
|
||||
|
||||
impl FormatNodeRule<StmtMatch> for FormatStmtMatch {
|
||||
fn fmt_fields(&self, _item: &StmtMatch, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtNonlocal;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtNonlocal;
|
||||
|
||||
impl FormatNodeRule<StmtNonlocal> for FormatStmtNonlocal {
|
||||
fn fmt_fields(&self, _item: &StmtNonlocal, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_pass.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_pass.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtPass;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtPass;
|
||||
|
||||
impl FormatNodeRule<StmtPass> for FormatStmtPass {
|
||||
fn fmt_fields(&self, _item: &StmtPass, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_raise.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_raise.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtRaise;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtRaise;
|
||||
|
||||
impl FormatNodeRule<StmtRaise> for FormatStmtRaise {
|
||||
fn fmt_fields(&self, _item: &StmtRaise, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_return.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_return.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtReturn;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtReturn;
|
||||
|
||||
impl FormatNodeRule<StmtReturn> for FormatStmtReturn {
|
||||
fn fmt_fields(&self, _item: &StmtReturn, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_try.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_try.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtTry;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtTry;
|
||||
|
||||
impl FormatNodeRule<StmtTry> for FormatStmtTry {
|
||||
fn fmt_fields(&self, _item: &StmtTry, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_try_star.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_try_star.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtTryStar;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtTryStar;
|
||||
|
||||
impl FormatNodeRule<StmtTryStar> for FormatStmtTryStar {
|
||||
fn fmt_fields(&self, _item: &StmtTryStar, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_while.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_while.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtWhile;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtWhile;
|
||||
|
||||
impl FormatNodeRule<StmtWhile> for FormatStmtWhile {
|
||||
fn fmt_fields(&self, _item: &StmtWhile, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/statement/stmt_with.rs
Normal file
12
crates/ruff_python_formatter/src/statement/stmt_with.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::StmtWith;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtWith;
|
||||
|
||||
impl FormatNodeRule<StmtWith> for FormatStmtWith {
|
||||
fn fmt_fields(&self, _item: &StmtWith, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue