mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-25 14:03:51 +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
12
crates/ruff_python_formatter/src/other/alias.rs
Normal file
12
crates/ruff_python_formatter/src/other/alias.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Alias;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatAlias;
|
||||
|
||||
impl FormatNodeRule<Alias> for FormatAlias {
|
||||
fn fmt_fields(&self, _item: &Alias, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/arg.rs
Normal file
12
crates/ruff_python_formatter/src/other/arg.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Arg;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatArg;
|
||||
|
||||
impl FormatNodeRule<Arg> for FormatArg {
|
||||
fn fmt_fields(&self, _item: &Arg, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/arguments.rs
Normal file
12
crates/ruff_python_formatter/src/other/arguments.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Arguments;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatArguments;
|
||||
|
||||
impl FormatNodeRule<Arguments> for FormatArguments {
|
||||
fn fmt_fields(&self, _item: &Arguments, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/comprehension.rs
Normal file
12
crates/ruff_python_formatter/src/other/comprehension.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Comprehension;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatComprehension;
|
||||
|
||||
impl FormatNodeRule<Comprehension> for FormatComprehension {
|
||||
fn fmt_fields(&self, _item: &Comprehension, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::ExcepthandlerExceptHandler;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExcepthandlerExceptHandler;
|
||||
|
||||
impl FormatNodeRule<ExcepthandlerExceptHandler> for FormatExcepthandlerExceptHandler {
|
||||
fn fmt_fields(
|
||||
&self,
|
||||
_item: &ExcepthandlerExceptHandler,
|
||||
_f: &mut PyFormatter,
|
||||
) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/keyword.rs
Normal file
12
crates/ruff_python_formatter/src/other/keyword.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Keyword;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatKeyword;
|
||||
|
||||
impl FormatNodeRule<Keyword> for FormatKeyword {
|
||||
fn fmt_fields(&self, _item: &Keyword, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/match_case.rs
Normal file
12
crates/ruff_python_formatter/src/other/match_case.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::MatchCase;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatMatchCase;
|
||||
|
||||
impl FormatNodeRule<MatchCase> for FormatMatchCase {
|
||||
fn fmt_fields(&self, _item: &MatchCase, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
9
crates/ruff_python_formatter/src/other/mod.rs
Normal file
9
crates/ruff_python_formatter/src/other/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
pub(crate) mod alias;
|
||||
pub(crate) mod arg;
|
||||
pub(crate) mod arguments;
|
||||
pub(crate) mod comprehension;
|
||||
pub(crate) mod excepthandler_except_handler;
|
||||
pub(crate) mod keyword;
|
||||
pub(crate) mod match_case;
|
||||
pub(crate) mod type_ignore_type_ignore;
|
||||
pub(crate) mod withitem;
|
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::TypeIgnoreTypeIgnore;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatTypeIgnoreTypeIgnore;
|
||||
|
||||
impl FormatNodeRule<TypeIgnoreTypeIgnore> for FormatTypeIgnoreTypeIgnore {
|
||||
fn fmt_fields(&self, _item: &TypeIgnoreTypeIgnore, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
crates/ruff_python_formatter/src/other/withitem.rs
Normal file
12
crates/ruff_python_formatter/src/other/withitem.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_parser::ast::Withitem;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatWithitem;
|
||||
|
||||
impl FormatNodeRule<Withitem> for FormatWithitem {
|
||||
fn fmt_fields(&self, _item: &Withitem, _f: &mut PyFormatter) -> FormatResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue