From 0945803427ef971724ce29565cffb58ffc06166c Mon Sep 17 00:00:00 2001 From: konstin Date: Thu, 1 Jun 2023 08:38:53 +0200 Subject: [PATCH] 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 * Update crates/ruff_python_formatter/src/lib.rs Co-authored-by: Micha Reiser * stub out with Ok(()) again * Update crates/ruff_python_formatter/src/lib.rs Co-authored-by: Micha Reiser * 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 Co-authored-by: Micha Reiser --- crates/ruff_formatter/src/lib.rs | 67 +- crates/ruff_python_formatter/Docs.md | 8 + crates/ruff_python_formatter/generate.py | 152 + .../orphan_rules_in_the_formatter.svg | 16 + crates/ruff_python_formatter/src/context.rs | 16 +- .../src/expression/expr_attribute.rs | 12 + .../src/expression/expr_await.rs | 12 + .../src/expression/expr_bin_op.rs | 12 + .../src/expression/expr_bool_op.rs | 12 + .../src/expression/expr_call.rs | 12 + .../src/expression/expr_compare.rs | 12 + .../src/expression/expr_constant.rs | 12 + .../src/expression/expr_dict.rs | 12 + .../src/expression/expr_dict_comp.rs | 12 + .../src/expression/expr_formatted_value.rs | 12 + .../src/expression/expr_generator_exp.rs | 12 + .../src/expression/expr_if_exp.rs | 12 + .../src/expression/expr_joined_str.rs | 12 + .../src/expression/expr_lambda.rs | 12 + .../src/expression/expr_list.rs | 12 + .../src/expression/expr_list_comp.rs | 12 + .../src/expression/expr_name.rs | 12 + .../src/expression/expr_named_expr.rs | 12 + .../src/expression/expr_set.rs | 12 + .../src/expression/expr_set_comp.rs | 12 + .../src/expression/expr_slice.rs | 12 + .../src/expression/expr_starred.rs | 12 + .../src/expression/expr_subscript.rs | 12 + .../src/expression/expr_tuple.rs | 12 + .../src/expression/expr_unary_op.rs | 12 + .../src/expression/expr_yield.rs | 12 + .../src/expression/expr_yield_from.rs | 12 + .../src/expression/mod.rs | 27 + crates/ruff_python_formatter/src/generated.rs | 2860 +++++++++++++++++ crates/ruff_python_formatter/src/lib.rs | 75 +- .../ruff_python_formatter/src/module/mod.rs | 11 +- .../src/module/mod_expression.rs | 12 + .../src/module/mod_function_type.rs | 12 + .../src/module/mod_interactive.rs | 12 + .../src/module/mod_module.rs | 12 + .../ruff_python_formatter/src/other/alias.rs | 12 + crates/ruff_python_formatter/src/other/arg.rs | 12 + .../src/other/arguments.rs | 12 + .../src/other/comprehension.rs | 12 + .../src/other/excepthandler_except_handler.rs | 16 + .../src/other/keyword.rs | 12 + .../src/other/match_case.rs | 12 + crates/ruff_python_formatter/src/other/mod.rs | 9 + .../src/other/type_ignore_type_ignore.rs | 12 + .../src/other/withitem.rs | 12 + .../ruff_python_formatter/src/pattern/mod.rs | 8 + .../src/pattern/pattern_match_as.rs | 12 + .../src/pattern/pattern_match_class.rs | 12 + .../src/pattern/pattern_match_mapping.rs | 12 + .../src/pattern/pattern_match_or.rs | 12 + .../src/pattern/pattern_match_sequence.rs | 12 + .../src/pattern/pattern_match_singleton.rs | 12 + .../src/pattern/pattern_match_star.rs | 12 + .../src/pattern/pattern_match_value.rs | 12 + crates/ruff_python_formatter/src/prelude.rs | 2 +- .../src/statement/mod.rs | 27 + .../src/statement/stmt_ann_assign.rs | 12 + .../src/statement/stmt_assert.rs | 12 + .../src/statement/stmt_assign.rs | 12 + .../src/statement/stmt_async_for.rs | 12 + .../src/statement/stmt_async_function_def.rs | 12 + .../src/statement/stmt_async_with.rs | 12 + .../src/statement/stmt_aug_assign.rs | 12 + .../src/statement/stmt_break.rs | 12 + .../src/statement/stmt_class_def.rs | 12 + .../src/statement/stmt_continue.rs | 12 + .../src/statement/stmt_delete.rs | 12 + .../src/statement/stmt_expr.rs | 12 + .../src/statement/stmt_for.rs | 12 + .../src/statement/stmt_function_def.rs | 12 + .../src/statement/stmt_global.rs | 12 + .../src/statement/stmt_if.rs | 12 + .../src/statement/stmt_import.rs | 12 + .../src/statement/stmt_import_from.rs | 12 + .../src/statement/stmt_match.rs | 12 + .../src/statement/stmt_nonlocal.rs | 12 + .../src/statement/stmt_pass.rs | 12 + .../src/statement/stmt_raise.rs | 12 + .../src/statement/stmt_return.rs | 12 + .../src/statement/stmt_try.rs | 12 + .../src/statement/stmt_try_star.rs | 12 + .../src/statement/stmt_while.rs | 12 + .../src/statement/stmt_with.rs | 12 + 88 files changed, 4136 insertions(+), 46 deletions(-) create mode 100644 crates/ruff_python_formatter/Docs.md create mode 100644 crates/ruff_python_formatter/generate.py create mode 100644 crates/ruff_python_formatter/orphan_rules_in_the_formatter.svg create mode 100644 crates/ruff_python_formatter/src/expression/expr_attribute.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_await.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_bin_op.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_bool_op.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_call.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_compare.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_constant.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_dict.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_dict_comp.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_formatted_value.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_generator_exp.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_if_exp.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_joined_str.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_lambda.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_list.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_list_comp.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_name.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_named_expr.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_set.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_set_comp.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_slice.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_starred.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_subscript.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_tuple.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_unary_op.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_yield.rs create mode 100644 crates/ruff_python_formatter/src/expression/expr_yield_from.rs create mode 100644 crates/ruff_python_formatter/src/expression/mod.rs create mode 100644 crates/ruff_python_formatter/src/generated.rs create mode 100644 crates/ruff_python_formatter/src/module/mod_expression.rs create mode 100644 crates/ruff_python_formatter/src/module/mod_function_type.rs create mode 100644 crates/ruff_python_formatter/src/module/mod_interactive.rs create mode 100644 crates/ruff_python_formatter/src/module/mod_module.rs create mode 100644 crates/ruff_python_formatter/src/other/alias.rs create mode 100644 crates/ruff_python_formatter/src/other/arg.rs create mode 100644 crates/ruff_python_formatter/src/other/arguments.rs create mode 100644 crates/ruff_python_formatter/src/other/comprehension.rs create mode 100644 crates/ruff_python_formatter/src/other/excepthandler_except_handler.rs create mode 100644 crates/ruff_python_formatter/src/other/keyword.rs create mode 100644 crates/ruff_python_formatter/src/other/match_case.rs create mode 100644 crates/ruff_python_formatter/src/other/mod.rs create mode 100644 crates/ruff_python_formatter/src/other/type_ignore_type_ignore.rs create mode 100644 crates/ruff_python_formatter/src/other/withitem.rs create mode 100644 crates/ruff_python_formatter/src/pattern/mod.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_as.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_class.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_or.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_star.rs create mode 100644 crates/ruff_python_formatter/src/pattern/pattern_match_value.rs create mode 100644 crates/ruff_python_formatter/src/statement/mod.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_assert.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_assign.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_async_for.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_async_function_def.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_async_with.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_break.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_class_def.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_continue.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_delete.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_expr.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_for.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_function_def.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_global.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_if.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_import.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_import_from.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_match.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_pass.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_raise.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_return.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_try.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_try_star.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_while.rs create mode 100644 crates/ruff_python_formatter/src/statement/stmt_with.rs diff --git a/crates/ruff_formatter/src/lib.rs b/crates/ruff_formatter/src/lib.rs index 5498d03342..a5e9401412 100644 --- a/crates/ruff_formatter/src/lib.rs +++ b/crates/ruff_formatter/src/lib.rs @@ -39,6 +39,7 @@ use crate::formatter::Formatter; use crate::group_id::UniqueGroupIdBuilder; use crate::prelude::TagKind; use std::fmt::Debug; +use std::marker::PhantomData; use crate::format_element::document::Document; use crate::printer::{Printer, PrinterOptions}; @@ -517,14 +518,12 @@ impl Format for () { /// /// That's why the `ruff_js_formatter` crate must define a new-type that implements the formatting /// of `JsIfStatement`. -pub trait FormatRule { - type Context; - - fn fmt(&self, item: &T, f: &mut Formatter) -> FormatResult<()>; +pub trait FormatRule { + fn fmt(&self, item: &T, f: &mut Formatter) -> FormatResult<()>; } /// Rule that supports customizing how it formats an object of type `T`. -pub trait FormatRuleWithOptions: FormatRule { +pub trait FormatRuleWithOptions: FormatRule { type Options; /// Returns a new rule that uses the given options to format an object. @@ -564,26 +563,31 @@ pub trait FormatWithRule: Format { /// Formats the referenced `item` with the specified rule. #[derive(Debug, Copy, Clone)] -pub struct FormatRefWithRule<'a, T, R> +pub struct FormatRefWithRule<'a, T, R, C> where - R: FormatRule, + R: FormatRule, { item: &'a T, rule: R, + context: PhantomData, } -impl<'a, T, R> FormatRefWithRule<'a, T, R> +impl<'a, T, R, C> FormatRefWithRule<'a, T, R, C> where - R: FormatRule, + R: FormatRule, { pub fn new(item: &'a T, rule: R) -> Self { - Self { item, rule } + Self { + item, + rule, + context: PhantomData, + } } } -impl FormatRefWithRule<'_, T, R> +impl FormatRefWithRule<'_, T, R, C> where - R: FormatRuleWithOptions, + R: FormatRuleWithOptions, { pub fn with_options(mut self, options: O) -> Self { self.rule = self.rule.with_options(options); @@ -591,9 +595,9 @@ where } } -impl FormatWithRule for FormatRefWithRule<'_, T, R> +impl FormatWithRule for FormatRefWithRule<'_, T, R, C> where - R: FormatRule, + R: FormatRule, { type Item = T; @@ -602,32 +606,37 @@ where } } -impl Format for FormatRefWithRule<'_, T, R> +impl Format for FormatRefWithRule<'_, T, R, C> where - R: FormatRule, + R: FormatRule, { #[inline(always)] - fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { self.rule.fmt(self.item, f) } } /// Formats the `item` with the specified rule. #[derive(Debug, Clone)] -pub struct FormatOwnedWithRule +pub struct FormatOwnedWithRule where - R: FormatRule, + R: FormatRule, { item: T, rule: R, + context: PhantomData, } -impl FormatOwnedWithRule +impl FormatOwnedWithRule where - R: FormatRule, + R: FormatRule, { pub fn new(item: T, rule: R) -> Self { - Self { item, rule } + Self { + item, + rule, + context: PhantomData, + } } pub fn with_item(mut self, item: T) -> Self { @@ -640,19 +649,19 @@ where } } -impl Format for FormatOwnedWithRule +impl Format for FormatOwnedWithRule where - R: FormatRule, + R: FormatRule, { #[inline(always)] - fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { self.rule.fmt(&self.item, f) } } -impl FormatOwnedWithRule +impl FormatOwnedWithRule where - R: FormatRuleWithOptions, + R: FormatRuleWithOptions, { pub fn with_options(mut self, options: O) -> Self { self.rule = self.rule.with_options(options); @@ -660,9 +669,9 @@ where } } -impl FormatWithRule for FormatOwnedWithRule +impl FormatWithRule for FormatOwnedWithRule where - R: FormatRule, + R: FormatRule, { type Item = T; diff --git a/crates/ruff_python_formatter/Docs.md b/crates/ruff_python_formatter/Docs.md new file mode 100644 index 0000000000..326dd33b81 --- /dev/null +++ b/crates/ruff_python_formatter/Docs.md @@ -0,0 +1,8 @@ +# Rust Python Formatter + +For the formatter, we would like to implement `Format` from the rust_formatter crate for all AST +nodes, defined in the rustpython_parser crate. This violates rust's orphan rules. We therefore +generate in `generate.py` a newtype for each AST node with implementations of `FormatNodeRule`, +`FormatRule`, `AsFormat` and `IntoFormat` on it. + +![excalidraw showing the relationships between the different types](orphan_rules_in_the_formatter.svg) diff --git a/crates/ruff_python_formatter/generate.py b/crates/ruff_python_formatter/generate.py new file mode 100644 index 0000000000..91c1a393f7 --- /dev/null +++ b/crates/ruff_python_formatter/generate.py @@ -0,0 +1,152 @@ +"""See Docs.md""" + +# %% + +import re +from collections import defaultdict +from pathlib import Path +from subprocess import check_output + + +def rustfmt(code: str) -> str: + return check_output(["rustfmt", "--emit=stdout"], input=code, text=True) + + +# %% +# Read nodes + +root = Path( + check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip(), +) +nodes_file = ( + root.joinpath("crates") + .joinpath("ruff_python_ast") + .joinpath("src") + .joinpath("node.rs") + .read_text() +) +node_lines = ( + nodes_file.split("pub enum AnyNode {")[1].split("}")[0].strip().splitlines() +) +nodes = [node_line.split("(")[1].split("<")[0] for node_line in node_lines] +print(nodes) + +# %% +# Generate newtypes with dummy FormatNodeRule implementations + +out = ( + root.joinpath("crates") + .joinpath("ruff_python_formatter") + .joinpath("src") + .joinpath("generated.rs") +) +src = root.joinpath("crates").joinpath("ruff_python_formatter").joinpath("src") + +nodes_grouped = defaultdict(list) +# We rename because mod is a keyword in rust +groups = { + "mod": "module", + "expr": "expression", + "stmt": "statement", + "pattern": "pattern", + "other": "other", +} + + +def group_for_node(node: str) -> str: + for group in groups: + if node.startswith(group.title()): + return group + else: + return "other" + + +def to_camel_case(node: str) -> str: + """Converts PascalCase to camel_case""" + return re.sub("([A-Z])", r"_\1", node).lower().lstrip("_") + + +for node in nodes: + nodes_grouped[group_for_node(node)].append(node) + +for group, group_nodes in nodes_grouped.items(): + # These conflict with the manually content of the mod.rs files + # src.joinpath(groups[group]).mkdir(exist_ok=True) + # mod_section = "\n".join( + # f"pub(crate) mod {to_camel_case(node)};" for node in group_nodes + # ) + # src.joinpath(groups[group]).joinpath("mod.rs").write_text(rustfmt(mod_section)) + for node in group_nodes: + code = f""" + use crate::{{FormatNodeRule, PyFormatter}}; + use ruff_formatter::FormatResult; + use rustpython_parser::ast::{node}; + + #[derive(Default)] + pub struct Format{node}; + + impl FormatNodeRule<{node}> for Format{node} {{ + fn fmt_fields(&self, _item: &{node}, _f: &mut PyFormatter) -> FormatResult<()> {{ + Ok(()) + }} + }} + """.strip() # noqa: E501 + src.joinpath(groups[group]).joinpath(f"{to_camel_case(node)}.rs").write_text( + rustfmt(code) + ) + +# %% +# Generate `FormatRule`, `AsFormat` and `IntoFormat` + +generated = """//! This is a generated file. Don't modify it by hand! Run `scripts/generate.py` to re-generate the file. +use crate::context::PyFormatContext; +use crate::{AsFormat, FormatNodeRule, IntoFormat}; +use ruff_formatter::formatter::Formatter; +use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule}; +use rustpython_parser::ast; +""" # noqa: E501 +for node in nodes: + text = f""" + impl FormatRule> + for crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node} + {{ + #[inline] + fn fmt( + &self, + node: &ast::{node}, + f: &mut Formatter>, + ) -> FormatResult<()> {{ + FormatNodeRule::::fmt(self, node, f) + }} + }} + impl<'ast> AsFormat> for ast::{node} {{ + type Format<'a> = FormatRefWithRule< + 'a, + ast::{node}, + crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> {{ + FormatRefWithRule::new( + self, + crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}::default(), + ) + }} + }} + impl<'ast> IntoFormat> for ast::{node} {{ + type Format = FormatOwnedWithRule< + ast::{node}, + crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format {{ + FormatOwnedWithRule::new( + self, + crate::{groups[group_for_node(node)]}::{to_camel_case(node)}::Format{node}::default(), + ) + }} + }} + """ # noqa: E501 + generated += text + +out.write_text(rustfmt(generated)) diff --git a/crates/ruff_python_formatter/orphan_rules_in_the_formatter.svg b/crates/ruff_python_formatter/orphan_rules_in_the_formatter.svg new file mode 100644 index 0000000000..437ba37b30 --- /dev/null +++ b/crates/ruff_python_formatter/orphan_rules_in_the_formatter.svg @@ -0,0 +1,16 @@ + + + + + + + JsonArrayFormatNodeRuleFormatOwnedWithRuleFormatJsonArrayFormatFormatRefWithRuleAsFormatFormatterPython FormatterIntoFormatFormatRuleLike FormatRule, but withlanguage specific extensionsAlternative:struct FormatJsonArray<'a>(pub(crate) &'a JsonArray);struct IntoFormatJsonArray<'a>(pub(crate) JsonArray);impl Format for FormatJsonArray();write!(f, [FormatJsonArray(array)])InspirationPathBuf::display() -> DisplayWe put this inevery downstreamcrate to get .format()has JsonArray type paramGets FormatJsonArray,knows about JsonArraythrough FormatRuleimplementsreferencescallsour goalGetting Around the Orphan Rules in the Formatter \ No newline at end of file diff --git a/crates/ruff_python_formatter/src/context.rs b/crates/ruff_python_formatter/src/context.rs index affe9d7835..2cad567f78 100644 --- a/crates/ruff_python_formatter/src/context.rs +++ b/crates/ruff_python_formatter/src/context.rs @@ -4,13 +4,13 @@ use ruff_python_ast::source_code::Locator; use std::fmt::{Debug, Formatter}; #[derive(Clone)] -pub struct ASTFormatContext<'a> { +pub struct PyFormatContext<'a> { options: SimpleFormatOptions, contents: &'a str, comments: Comments<'a>, } -impl<'a> ASTFormatContext<'a> { +impl<'a> PyFormatContext<'a> { pub(crate) fn new( options: SimpleFormatOptions, contents: &'a str, @@ -23,11 +23,13 @@ impl<'a> ASTFormatContext<'a> { } } - pub fn contents(&self) -> &'a str { + #[allow(unused)] + pub(crate) fn contents(&self) -> &'a str { self.contents } - pub fn locator(&self) -> Locator<'a> { + #[allow(unused)] + pub(crate) fn locator(&self) -> Locator<'a> { Locator::new(self.contents) } @@ -37,7 +39,7 @@ impl<'a> ASTFormatContext<'a> { } } -impl FormatContext for ASTFormatContext<'_> { +impl FormatContext for PyFormatContext<'_> { type Options = SimpleFormatOptions; fn options(&self) -> &Self::Options { @@ -49,9 +51,9 @@ impl FormatContext for ASTFormatContext<'_> { } } -impl Debug for ASTFormatContext<'_> { +impl Debug for PyFormatContext<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ASTFormatContext") + f.debug_struct("PyFormatContext") .field("options", &self.options) .field("comments", &self.comments.debug(self.source_code())) .field("source", &self.contents) diff --git a/crates/ruff_python_formatter/src/expression/expr_attribute.rs b/crates/ruff_python_formatter/src/expression/expr_attribute.rs new file mode 100644 index 0000000000..8e2b50263e --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_attribute.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprAttribute; + +#[derive(Default)] +pub struct FormatExprAttribute; + +impl FormatNodeRule for FormatExprAttribute { + fn fmt_fields(&self, _item: &ExprAttribute, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_await.rs b/crates/ruff_python_formatter/src/expression/expr_await.rs new file mode 100644 index 0000000000..0840b04b1d --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_await.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprAwait; + +#[derive(Default)] +pub struct FormatExprAwait; + +impl FormatNodeRule for FormatExprAwait { + fn fmt_fields(&self, _item: &ExprAwait, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_bin_op.rs b/crates/ruff_python_formatter/src/expression/expr_bin_op.rs new file mode 100644 index 0000000000..706c9d1f8e --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_bin_op.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprBinOp; + +#[derive(Default)] +pub struct FormatExprBinOp; + +impl FormatNodeRule for FormatExprBinOp { + fn fmt_fields(&self, _item: &ExprBinOp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_bool_op.rs b/crates/ruff_python_formatter/src/expression/expr_bool_op.rs new file mode 100644 index 0000000000..f7e6a92b1a --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_bool_op.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprBoolOp; + +#[derive(Default)] +pub struct FormatExprBoolOp; + +impl FormatNodeRule for FormatExprBoolOp { + fn fmt_fields(&self, _item: &ExprBoolOp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_call.rs b/crates/ruff_python_formatter/src/expression/expr_call.rs new file mode 100644 index 0000000000..a5d7c6d1c9 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_call.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprCall; + +#[derive(Default)] +pub struct FormatExprCall; + +impl FormatNodeRule for FormatExprCall { + fn fmt_fields(&self, _item: &ExprCall, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_compare.rs b/crates/ruff_python_formatter/src/expression/expr_compare.rs new file mode 100644 index 0000000000..ab1e7da1d8 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_compare.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprCompare; + +#[derive(Default)] +pub struct FormatExprCompare; + +impl FormatNodeRule for FormatExprCompare { + fn fmt_fields(&self, _item: &ExprCompare, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_constant.rs b/crates/ruff_python_formatter/src/expression/expr_constant.rs new file mode 100644 index 0000000000..91bed7bd12 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_constant.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprConstant; + +#[derive(Default)] +pub struct FormatExprConstant; + +impl FormatNodeRule for FormatExprConstant { + fn fmt_fields(&self, _item: &ExprConstant, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_dict.rs b/crates/ruff_python_formatter/src/expression/expr_dict.rs new file mode 100644 index 0000000000..86b5038d92 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_dict.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprDict; + +#[derive(Default)] +pub struct FormatExprDict; + +impl FormatNodeRule for FormatExprDict { + fn fmt_fields(&self, _item: &ExprDict, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs b/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs new file mode 100644 index 0000000000..315ad62fc6 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_dict_comp.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprDictComp; + +#[derive(Default)] +pub struct FormatExprDictComp; + +impl FormatNodeRule for FormatExprDictComp { + fn fmt_fields(&self, _item: &ExprDictComp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_formatted_value.rs b/crates/ruff_python_formatter/src/expression/expr_formatted_value.rs new file mode 100644 index 0000000000..366ecf1e7b --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_formatted_value.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprFormattedValue; + +#[derive(Default)] +pub struct FormatExprFormattedValue; + +impl FormatNodeRule for FormatExprFormattedValue { + fn fmt_fields(&self, _item: &ExprFormattedValue, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs b/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs new file mode 100644 index 0000000000..52d655b612 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_generator_exp.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprGeneratorExp; + +#[derive(Default)] +pub struct FormatExprGeneratorExp; + +impl FormatNodeRule for FormatExprGeneratorExp { + fn fmt_fields(&self, _item: &ExprGeneratorExp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_if_exp.rs b/crates/ruff_python_formatter/src/expression/expr_if_exp.rs new file mode 100644 index 0000000000..d7e8a53c6e --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_if_exp.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprIfExp; + +#[derive(Default)] +pub struct FormatExprIfExp; + +impl FormatNodeRule for FormatExprIfExp { + fn fmt_fields(&self, _item: &ExprIfExp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_joined_str.rs b/crates/ruff_python_formatter/src/expression/expr_joined_str.rs new file mode 100644 index 0000000000..c0892f9b44 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_joined_str.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprJoinedStr; + +#[derive(Default)] +pub struct FormatExprJoinedStr; + +impl FormatNodeRule for FormatExprJoinedStr { + fn fmt_fields(&self, _item: &ExprJoinedStr, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_lambda.rs b/crates/ruff_python_formatter/src/expression/expr_lambda.rs new file mode 100644 index 0000000000..507c1af29b --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_lambda.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprLambda; + +#[derive(Default)] +pub struct FormatExprLambda; + +impl FormatNodeRule for FormatExprLambda { + fn fmt_fields(&self, _item: &ExprLambda, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_list.rs b/crates/ruff_python_formatter/src/expression/expr_list.rs new file mode 100644 index 0000000000..0161869284 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_list.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprList; + +#[derive(Default)] +pub struct FormatExprList; + +impl FormatNodeRule for FormatExprList { + fn fmt_fields(&self, _item: &ExprList, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_list_comp.rs b/crates/ruff_python_formatter/src/expression/expr_list_comp.rs new file mode 100644 index 0000000000..64fe42874f --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_list_comp.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprListComp; + +#[derive(Default)] +pub struct FormatExprListComp; + +impl FormatNodeRule for FormatExprListComp { + fn fmt_fields(&self, _item: &ExprListComp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_name.rs b/crates/ruff_python_formatter/src/expression/expr_name.rs new file mode 100644 index 0000000000..da8294049b --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_name.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprName; + +#[derive(Default)] +pub struct FormatExprName; + +impl FormatNodeRule for FormatExprName { + fn fmt_fields(&self, _item: &ExprName, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_named_expr.rs b/crates/ruff_python_formatter/src/expression/expr_named_expr.rs new file mode 100644 index 0000000000..457ce99d40 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_named_expr.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprNamedExpr; + +#[derive(Default)] +pub struct FormatExprNamedExpr; + +impl FormatNodeRule for FormatExprNamedExpr { + fn fmt_fields(&self, _item: &ExprNamedExpr, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_set.rs b/crates/ruff_python_formatter/src/expression/expr_set.rs new file mode 100644 index 0000000000..d1b239b925 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_set.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprSet; + +#[derive(Default)] +pub struct FormatExprSet; + +impl FormatNodeRule for FormatExprSet { + fn fmt_fields(&self, _item: &ExprSet, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_set_comp.rs b/crates/ruff_python_formatter/src/expression/expr_set_comp.rs new file mode 100644 index 0000000000..69021f32fd --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_set_comp.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprSetComp; + +#[derive(Default)] +pub struct FormatExprSetComp; + +impl FormatNodeRule for FormatExprSetComp { + fn fmt_fields(&self, _item: &ExprSetComp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_slice.rs b/crates/ruff_python_formatter/src/expression/expr_slice.rs new file mode 100644 index 0000000000..aa00b370f3 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_slice.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprSlice; + +#[derive(Default)] +pub struct FormatExprSlice; + +impl FormatNodeRule for FormatExprSlice { + fn fmt_fields(&self, _item: &ExprSlice, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_starred.rs b/crates/ruff_python_formatter/src/expression/expr_starred.rs new file mode 100644 index 0000000000..6a5278e0d1 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_starred.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprStarred; + +#[derive(Default)] +pub struct FormatExprStarred; + +impl FormatNodeRule for FormatExprStarred { + fn fmt_fields(&self, _item: &ExprStarred, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_subscript.rs b/crates/ruff_python_formatter/src/expression/expr_subscript.rs new file mode 100644 index 0000000000..9d68613e8d --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_subscript.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprSubscript; + +#[derive(Default)] +pub struct FormatExprSubscript; + +impl FormatNodeRule for FormatExprSubscript { + fn fmt_fields(&self, _item: &ExprSubscript, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_tuple.rs b/crates/ruff_python_formatter/src/expression/expr_tuple.rs new file mode 100644 index 0000000000..e3eab13185 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_tuple.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprTuple; + +#[derive(Default)] +pub struct FormatExprTuple; + +impl FormatNodeRule for FormatExprTuple { + fn fmt_fields(&self, _item: &ExprTuple, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_unary_op.rs b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs new file mode 100644 index 0000000000..d6f0f0244a --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprUnaryOp; + +#[derive(Default)] +pub struct FormatExprUnaryOp; + +impl FormatNodeRule for FormatExprUnaryOp { + fn fmt_fields(&self, _item: &ExprUnaryOp, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_yield.rs b/crates/ruff_python_formatter/src/expression/expr_yield.rs new file mode 100644 index 0000000000..26f046b3f7 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_yield.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprYield; + +#[derive(Default)] +pub struct FormatExprYield; + +impl FormatNodeRule for FormatExprYield { + fn fmt_fields(&self, _item: &ExprYield, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/expr_yield_from.rs b/crates/ruff_python_formatter/src/expression/expr_yield_from.rs new file mode 100644 index 0000000000..334bcbe3f7 --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/expr_yield_from.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExprYieldFrom; + +#[derive(Default)] +pub struct FormatExprYieldFrom; + +impl FormatNodeRule for FormatExprYieldFrom { + fn fmt_fields(&self, _item: &ExprYieldFrom, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs new file mode 100644 index 0000000000..dd73ca1f6d --- /dev/null +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -0,0 +1,27 @@ +pub(crate) mod expr_attribute; +pub(crate) mod expr_await; +pub(crate) mod expr_bin_op; +pub(crate) mod expr_bool_op; +pub(crate) mod expr_call; +pub(crate) mod expr_compare; +pub(crate) mod expr_constant; +pub(crate) mod expr_dict; +pub(crate) mod expr_dict_comp; +pub(crate) mod expr_formatted_value; +pub(crate) mod expr_generator_exp; +pub(crate) mod expr_if_exp; +pub(crate) mod expr_joined_str; +pub(crate) mod expr_lambda; +pub(crate) mod expr_list; +pub(crate) mod expr_list_comp; +pub(crate) mod expr_name; +pub(crate) mod expr_named_expr; +pub(crate) mod expr_set; +pub(crate) mod expr_set_comp; +pub(crate) mod expr_slice; +pub(crate) mod expr_starred; +pub(crate) mod expr_subscript; +pub(crate) mod expr_tuple; +pub(crate) mod expr_unary_op; +pub(crate) mod expr_yield; +pub(crate) mod expr_yield_from; diff --git a/crates/ruff_python_formatter/src/generated.rs b/crates/ruff_python_formatter/src/generated.rs new file mode 100644 index 0000000000..3aeaccfe3f --- /dev/null +++ b/crates/ruff_python_formatter/src/generated.rs @@ -0,0 +1,2860 @@ +//! This is a generated file. Don't modify it by hand! Run `scripts/generate.py` to re-generate the file. +use crate::context::PyFormatContext; +use crate::{AsFormat, FormatNodeRule, IntoFormat}; +use ruff_formatter::formatter::Formatter; +use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule}; +use rustpython_parser::ast; + +impl FormatRule> + for crate::module::mod_module::FormatModModule +{ + #[inline] + fn fmt( + &self, + node: &ast::ModModule, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ModModule { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ModModule, + crate::module::mod_module::FormatModModule, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::module::mod_module::FormatModModule::default()) + } +} +impl<'ast> IntoFormat> for ast::ModModule { + type Format = FormatOwnedWithRule< + ast::ModModule, + crate::module::mod_module::FormatModModule, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::module::mod_module::FormatModModule::default()) + } +} + +impl FormatRule> + for crate::module::mod_interactive::FormatModInteractive +{ + #[inline] + fn fmt( + &self, + node: &ast::ModInteractive, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ModInteractive { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ModInteractive, + crate::module::mod_interactive::FormatModInteractive, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::module::mod_interactive::FormatModInteractive::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ModInteractive { + type Format = FormatOwnedWithRule< + ast::ModInteractive, + crate::module::mod_interactive::FormatModInteractive, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::module::mod_interactive::FormatModInteractive::default(), + ) + } +} + +impl FormatRule> + for crate::module::mod_expression::FormatModExpression +{ + #[inline] + fn fmt( + &self, + node: &ast::ModExpression, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ModExpression { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ModExpression, + crate::module::mod_expression::FormatModExpression, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::module::mod_expression::FormatModExpression::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ModExpression { + type Format = FormatOwnedWithRule< + ast::ModExpression, + crate::module::mod_expression::FormatModExpression, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::module::mod_expression::FormatModExpression::default(), + ) + } +} + +impl FormatRule> + for crate::module::mod_function_type::FormatModFunctionType +{ + #[inline] + fn fmt( + &self, + node: &ast::ModFunctionType, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ModFunctionType { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ModFunctionType, + crate::module::mod_function_type::FormatModFunctionType, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::module::mod_function_type::FormatModFunctionType::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ModFunctionType { + type Format = FormatOwnedWithRule< + ast::ModFunctionType, + crate::module::mod_function_type::FormatModFunctionType, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::module::mod_function_type::FormatModFunctionType::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_function_def::FormatStmtFunctionDef +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtFunctionDef, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtFunctionDef { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtFunctionDef, + crate::statement::stmt_function_def::FormatStmtFunctionDef, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_function_def::FormatStmtFunctionDef::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtFunctionDef { + type Format = FormatOwnedWithRule< + ast::StmtFunctionDef, + crate::statement::stmt_function_def::FormatStmtFunctionDef, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_function_def::FormatStmtFunctionDef::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_async_function_def::FormatStmtAsyncFunctionDef +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAsyncFunctionDef, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAsyncFunctionDef { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAsyncFunctionDef, + crate::statement::stmt_async_function_def::FormatStmtAsyncFunctionDef, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_async_function_def::FormatStmtAsyncFunctionDef::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAsyncFunctionDef { + type Format = FormatOwnedWithRule< + ast::StmtAsyncFunctionDef, + crate::statement::stmt_async_function_def::FormatStmtAsyncFunctionDef, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_async_function_def::FormatStmtAsyncFunctionDef::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_class_def::FormatStmtClassDef +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtClassDef, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtClassDef { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtClassDef, + crate::statement::stmt_class_def::FormatStmtClassDef, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_class_def::FormatStmtClassDef::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtClassDef { + type Format = FormatOwnedWithRule< + ast::StmtClassDef, + crate::statement::stmt_class_def::FormatStmtClassDef, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_class_def::FormatStmtClassDef::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_return::FormatStmtReturn +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtReturn, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtReturn { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtReturn, + crate::statement::stmt_return::FormatStmtReturn, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_return::FormatStmtReturn::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtReturn { + type Format = FormatOwnedWithRule< + ast::StmtReturn, + crate::statement::stmt_return::FormatStmtReturn, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_return::FormatStmtReturn::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_delete::FormatStmtDelete +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtDelete, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtDelete { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtDelete, + crate::statement::stmt_delete::FormatStmtDelete, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_delete::FormatStmtDelete::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtDelete { + type Format = FormatOwnedWithRule< + ast::StmtDelete, + crate::statement::stmt_delete::FormatStmtDelete, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_delete::FormatStmtDelete::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_assign::FormatStmtAssign +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAssign, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAssign { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAssign, + crate::statement::stmt_assign::FormatStmtAssign, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_assign::FormatStmtAssign::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAssign { + type Format = FormatOwnedWithRule< + ast::StmtAssign, + crate::statement::stmt_assign::FormatStmtAssign, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_assign::FormatStmtAssign::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_aug_assign::FormatStmtAugAssign +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAugAssign, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAugAssign { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAugAssign, + crate::statement::stmt_aug_assign::FormatStmtAugAssign, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_aug_assign::FormatStmtAugAssign::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAugAssign { + type Format = FormatOwnedWithRule< + ast::StmtAugAssign, + crate::statement::stmt_aug_assign::FormatStmtAugAssign, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_aug_assign::FormatStmtAugAssign::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_ann_assign::FormatStmtAnnAssign +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAnnAssign, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAnnAssign { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAnnAssign, + crate::statement::stmt_ann_assign::FormatStmtAnnAssign, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_ann_assign::FormatStmtAnnAssign::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAnnAssign { + type Format = FormatOwnedWithRule< + ast::StmtAnnAssign, + crate::statement::stmt_ann_assign::FormatStmtAnnAssign, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_ann_assign::FormatStmtAnnAssign::default(), + ) + } +} + +impl FormatRule> for crate::statement::stmt_for::FormatStmtFor { + #[inline] + fn fmt(&self, node: &ast::StmtFor, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtFor { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtFor, + crate::statement::stmt_for::FormatStmtFor, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_for::FormatStmtFor::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtFor { + type Format = FormatOwnedWithRule< + ast::StmtFor, + crate::statement::stmt_for::FormatStmtFor, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_for::FormatStmtFor::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_async_for::FormatStmtAsyncFor +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAsyncFor, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAsyncFor { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAsyncFor, + crate::statement::stmt_async_for::FormatStmtAsyncFor, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_async_for::FormatStmtAsyncFor::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAsyncFor { + type Format = FormatOwnedWithRule< + ast::StmtAsyncFor, + crate::statement::stmt_async_for::FormatStmtAsyncFor, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_async_for::FormatStmtAsyncFor::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_while::FormatStmtWhile +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtWhile, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtWhile { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtWhile, + crate::statement::stmt_while::FormatStmtWhile, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_while::FormatStmtWhile::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtWhile { + type Format = FormatOwnedWithRule< + ast::StmtWhile, + crate::statement::stmt_while::FormatStmtWhile, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_while::FormatStmtWhile::default(), + ) + } +} + +impl FormatRule> for crate::statement::stmt_if::FormatStmtIf { + #[inline] + fn fmt(&self, node: &ast::StmtIf, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtIf { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtIf, + crate::statement::stmt_if::FormatStmtIf, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_if::FormatStmtIf::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtIf { + type Format = FormatOwnedWithRule< + ast::StmtIf, + crate::statement::stmt_if::FormatStmtIf, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_if::FormatStmtIf::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_with::FormatStmtWith +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtWith, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtWith { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtWith, + crate::statement::stmt_with::FormatStmtWith, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_with::FormatStmtWith::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtWith { + type Format = FormatOwnedWithRule< + ast::StmtWith, + crate::statement::stmt_with::FormatStmtWith, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_with::FormatStmtWith::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_async_with::FormatStmtAsyncWith +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAsyncWith, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAsyncWith { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAsyncWith, + crate::statement::stmt_async_with::FormatStmtAsyncWith, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_async_with::FormatStmtAsyncWith::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAsyncWith { + type Format = FormatOwnedWithRule< + ast::StmtAsyncWith, + crate::statement::stmt_async_with::FormatStmtAsyncWith, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_async_with::FormatStmtAsyncWith::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_match::FormatStmtMatch +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtMatch, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtMatch { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtMatch, + crate::statement::stmt_match::FormatStmtMatch, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_match::FormatStmtMatch::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtMatch { + type Format = FormatOwnedWithRule< + ast::StmtMatch, + crate::statement::stmt_match::FormatStmtMatch, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_match::FormatStmtMatch::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_raise::FormatStmtRaise +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtRaise, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtRaise { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtRaise, + crate::statement::stmt_raise::FormatStmtRaise, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_raise::FormatStmtRaise::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtRaise { + type Format = FormatOwnedWithRule< + ast::StmtRaise, + crate::statement::stmt_raise::FormatStmtRaise, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_raise::FormatStmtRaise::default(), + ) + } +} + +impl FormatRule> for crate::statement::stmt_try::FormatStmtTry { + #[inline] + fn fmt(&self, node: &ast::StmtTry, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtTry { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtTry, + crate::statement::stmt_try::FormatStmtTry, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_try::FormatStmtTry::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtTry { + type Format = FormatOwnedWithRule< + ast::StmtTry, + crate::statement::stmt_try::FormatStmtTry, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_try::FormatStmtTry::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_try_star::FormatStmtTryStar +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtTryStar, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtTryStar { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtTryStar, + crate::statement::stmt_try_star::FormatStmtTryStar, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_try_star::FormatStmtTryStar::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtTryStar { + type Format = FormatOwnedWithRule< + ast::StmtTryStar, + crate::statement::stmt_try_star::FormatStmtTryStar, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_try_star::FormatStmtTryStar::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_assert::FormatStmtAssert +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtAssert, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtAssert { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtAssert, + crate::statement::stmt_assert::FormatStmtAssert, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_assert::FormatStmtAssert::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtAssert { + type Format = FormatOwnedWithRule< + ast::StmtAssert, + crate::statement::stmt_assert::FormatStmtAssert, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_assert::FormatStmtAssert::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_import::FormatStmtImport +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtImport, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtImport { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtImport, + crate::statement::stmt_import::FormatStmtImport, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_import::FormatStmtImport::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtImport { + type Format = FormatOwnedWithRule< + ast::StmtImport, + crate::statement::stmt_import::FormatStmtImport, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_import::FormatStmtImport::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_import_from::FormatStmtImportFrom +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtImportFrom, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtImportFrom { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtImportFrom, + crate::statement::stmt_import_from::FormatStmtImportFrom, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_import_from::FormatStmtImportFrom::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtImportFrom { + type Format = FormatOwnedWithRule< + ast::StmtImportFrom, + crate::statement::stmt_import_from::FormatStmtImportFrom, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_import_from::FormatStmtImportFrom::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_global::FormatStmtGlobal +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtGlobal, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtGlobal { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtGlobal, + crate::statement::stmt_global::FormatStmtGlobal, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_global::FormatStmtGlobal::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtGlobal { + type Format = FormatOwnedWithRule< + ast::StmtGlobal, + crate::statement::stmt_global::FormatStmtGlobal, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_global::FormatStmtGlobal::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_nonlocal::FormatStmtNonlocal +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtNonlocal, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtNonlocal { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtNonlocal, + crate::statement::stmt_nonlocal::FormatStmtNonlocal, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_nonlocal::FormatStmtNonlocal::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtNonlocal { + type Format = FormatOwnedWithRule< + ast::StmtNonlocal, + crate::statement::stmt_nonlocal::FormatStmtNonlocal, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_nonlocal::FormatStmtNonlocal::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_expr::FormatStmtExpr +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtExpr, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtExpr { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtExpr, + crate::statement::stmt_expr::FormatStmtExpr, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_expr::FormatStmtExpr::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtExpr { + type Format = FormatOwnedWithRule< + ast::StmtExpr, + crate::statement::stmt_expr::FormatStmtExpr, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_expr::FormatStmtExpr::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_pass::FormatStmtPass +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtPass, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtPass { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtPass, + crate::statement::stmt_pass::FormatStmtPass, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::statement::stmt_pass::FormatStmtPass::default()) + } +} +impl<'ast> IntoFormat> for ast::StmtPass { + type Format = FormatOwnedWithRule< + ast::StmtPass, + crate::statement::stmt_pass::FormatStmtPass, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::statement::stmt_pass::FormatStmtPass::default()) + } +} + +impl FormatRule> + for crate::statement::stmt_break::FormatStmtBreak +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtBreak, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtBreak { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtBreak, + crate::statement::stmt_break::FormatStmtBreak, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_break::FormatStmtBreak::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtBreak { + type Format = FormatOwnedWithRule< + ast::StmtBreak, + crate::statement::stmt_break::FormatStmtBreak, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_break::FormatStmtBreak::default(), + ) + } +} + +impl FormatRule> + for crate::statement::stmt_continue::FormatStmtContinue +{ + #[inline] + fn fmt( + &self, + node: &ast::StmtContinue, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::StmtContinue { + type Format<'a> = FormatRefWithRule< + 'a, + ast::StmtContinue, + crate::statement::stmt_continue::FormatStmtContinue, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::statement::stmt_continue::FormatStmtContinue::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::StmtContinue { + type Format = FormatOwnedWithRule< + ast::StmtContinue, + crate::statement::stmt_continue::FormatStmtContinue, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::statement::stmt_continue::FormatStmtContinue::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_bool_op::FormatExprBoolOp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprBoolOp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprBoolOp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprBoolOp, + crate::expression::expr_bool_op::FormatExprBoolOp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_bool_op::FormatExprBoolOp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprBoolOp { + type Format = FormatOwnedWithRule< + ast::ExprBoolOp, + crate::expression::expr_bool_op::FormatExprBoolOp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_bool_op::FormatExprBoolOp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_named_expr::FormatExprNamedExpr +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprNamedExpr, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprNamedExpr { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprNamedExpr, + crate::expression::expr_named_expr::FormatExprNamedExpr, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_named_expr::FormatExprNamedExpr::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprNamedExpr { + type Format = FormatOwnedWithRule< + ast::ExprNamedExpr, + crate::expression::expr_named_expr::FormatExprNamedExpr, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_named_expr::FormatExprNamedExpr::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_bin_op::FormatExprBinOp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprBinOp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprBinOp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprBinOp, + crate::expression::expr_bin_op::FormatExprBinOp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_bin_op::FormatExprBinOp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprBinOp { + type Format = FormatOwnedWithRule< + ast::ExprBinOp, + crate::expression::expr_bin_op::FormatExprBinOp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_bin_op::FormatExprBinOp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_unary_op::FormatExprUnaryOp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprUnaryOp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprUnaryOp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprUnaryOp, + crate::expression::expr_unary_op::FormatExprUnaryOp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_unary_op::FormatExprUnaryOp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprUnaryOp { + type Format = FormatOwnedWithRule< + ast::ExprUnaryOp, + crate::expression::expr_unary_op::FormatExprUnaryOp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_unary_op::FormatExprUnaryOp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_lambda::FormatExprLambda +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprLambda, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprLambda { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprLambda, + crate::expression::expr_lambda::FormatExprLambda, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_lambda::FormatExprLambda::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprLambda { + type Format = FormatOwnedWithRule< + ast::ExprLambda, + crate::expression::expr_lambda::FormatExprLambda, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_lambda::FormatExprLambda::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_if_exp::FormatExprIfExp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprIfExp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprIfExp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprIfExp, + crate::expression::expr_if_exp::FormatExprIfExp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_if_exp::FormatExprIfExp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprIfExp { + type Format = FormatOwnedWithRule< + ast::ExprIfExp, + crate::expression::expr_if_exp::FormatExprIfExp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_if_exp::FormatExprIfExp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_dict::FormatExprDict +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprDict, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprDict { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprDict, + crate::expression::expr_dict::FormatExprDict, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_dict::FormatExprDict::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprDict { + type Format = FormatOwnedWithRule< + ast::ExprDict, + crate::expression::expr_dict::FormatExprDict, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_dict::FormatExprDict::default(), + ) + } +} + +impl FormatRule> for crate::expression::expr_set::FormatExprSet { + #[inline] + fn fmt(&self, node: &ast::ExprSet, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprSet { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprSet, + crate::expression::expr_set::FormatExprSet, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::expression::expr_set::FormatExprSet::default()) + } +} +impl<'ast> IntoFormat> for ast::ExprSet { + type Format = FormatOwnedWithRule< + ast::ExprSet, + crate::expression::expr_set::FormatExprSet, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::expression::expr_set::FormatExprSet::default()) + } +} + +impl FormatRule> + for crate::expression::expr_list_comp::FormatExprListComp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprListComp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprListComp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprListComp, + crate::expression::expr_list_comp::FormatExprListComp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_list_comp::FormatExprListComp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprListComp { + type Format = FormatOwnedWithRule< + ast::ExprListComp, + crate::expression::expr_list_comp::FormatExprListComp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_list_comp::FormatExprListComp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_set_comp::FormatExprSetComp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprSetComp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprSetComp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprSetComp, + crate::expression::expr_set_comp::FormatExprSetComp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_set_comp::FormatExprSetComp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprSetComp { + type Format = FormatOwnedWithRule< + ast::ExprSetComp, + crate::expression::expr_set_comp::FormatExprSetComp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_set_comp::FormatExprSetComp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_dict_comp::FormatExprDictComp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprDictComp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprDictComp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprDictComp, + crate::expression::expr_dict_comp::FormatExprDictComp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_dict_comp::FormatExprDictComp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprDictComp { + type Format = FormatOwnedWithRule< + ast::ExprDictComp, + crate::expression::expr_dict_comp::FormatExprDictComp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_dict_comp::FormatExprDictComp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_generator_exp::FormatExprGeneratorExp +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprGeneratorExp, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprGeneratorExp { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprGeneratorExp, + crate::expression::expr_generator_exp::FormatExprGeneratorExp, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_generator_exp::FormatExprGeneratorExp::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprGeneratorExp { + type Format = FormatOwnedWithRule< + ast::ExprGeneratorExp, + crate::expression::expr_generator_exp::FormatExprGeneratorExp, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_generator_exp::FormatExprGeneratorExp::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_await::FormatExprAwait +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprAwait, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprAwait { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprAwait, + crate::expression::expr_await::FormatExprAwait, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_await::FormatExprAwait::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprAwait { + type Format = FormatOwnedWithRule< + ast::ExprAwait, + crate::expression::expr_await::FormatExprAwait, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_await::FormatExprAwait::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_yield::FormatExprYield +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprYield, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprYield { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprYield, + crate::expression::expr_yield::FormatExprYield, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_yield::FormatExprYield::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprYield { + type Format = FormatOwnedWithRule< + ast::ExprYield, + crate::expression::expr_yield::FormatExprYield, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_yield::FormatExprYield::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_yield_from::FormatExprYieldFrom +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprYieldFrom, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprYieldFrom { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprYieldFrom, + crate::expression::expr_yield_from::FormatExprYieldFrom, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_yield_from::FormatExprYieldFrom::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprYieldFrom { + type Format = FormatOwnedWithRule< + ast::ExprYieldFrom, + crate::expression::expr_yield_from::FormatExprYieldFrom, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_yield_from::FormatExprYieldFrom::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_compare::FormatExprCompare +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprCompare, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprCompare { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprCompare, + crate::expression::expr_compare::FormatExprCompare, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_compare::FormatExprCompare::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprCompare { + type Format = FormatOwnedWithRule< + ast::ExprCompare, + crate::expression::expr_compare::FormatExprCompare, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_compare::FormatExprCompare::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_call::FormatExprCall +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprCall, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprCall { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprCall, + crate::expression::expr_call::FormatExprCall, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_call::FormatExprCall::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprCall { + type Format = FormatOwnedWithRule< + ast::ExprCall, + crate::expression::expr_call::FormatExprCall, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_call::FormatExprCall::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_formatted_value::FormatExprFormattedValue +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprFormattedValue, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprFormattedValue { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprFormattedValue, + crate::expression::expr_formatted_value::FormatExprFormattedValue, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_formatted_value::FormatExprFormattedValue::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprFormattedValue { + type Format = FormatOwnedWithRule< + ast::ExprFormattedValue, + crate::expression::expr_formatted_value::FormatExprFormattedValue, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_formatted_value::FormatExprFormattedValue::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_joined_str::FormatExprJoinedStr +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprJoinedStr, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprJoinedStr { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprJoinedStr, + crate::expression::expr_joined_str::FormatExprJoinedStr, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_joined_str::FormatExprJoinedStr::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprJoinedStr { + type Format = FormatOwnedWithRule< + ast::ExprJoinedStr, + crate::expression::expr_joined_str::FormatExprJoinedStr, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_joined_str::FormatExprJoinedStr::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_constant::FormatExprConstant +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprConstant, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprConstant { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprConstant, + crate::expression::expr_constant::FormatExprConstant, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_constant::FormatExprConstant::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprConstant { + type Format = FormatOwnedWithRule< + ast::ExprConstant, + crate::expression::expr_constant::FormatExprConstant, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_constant::FormatExprConstant::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_attribute::FormatExprAttribute +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprAttribute, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprAttribute { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprAttribute, + crate::expression::expr_attribute::FormatExprAttribute, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_attribute::FormatExprAttribute::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprAttribute { + type Format = FormatOwnedWithRule< + ast::ExprAttribute, + crate::expression::expr_attribute::FormatExprAttribute, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_attribute::FormatExprAttribute::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_subscript::FormatExprSubscript +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprSubscript, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprSubscript { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprSubscript, + crate::expression::expr_subscript::FormatExprSubscript, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_subscript::FormatExprSubscript::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprSubscript { + type Format = FormatOwnedWithRule< + ast::ExprSubscript, + crate::expression::expr_subscript::FormatExprSubscript, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_subscript::FormatExprSubscript::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_starred::FormatExprStarred +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprStarred, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprStarred { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprStarred, + crate::expression::expr_starred::FormatExprStarred, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_starred::FormatExprStarred::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprStarred { + type Format = FormatOwnedWithRule< + ast::ExprStarred, + crate::expression::expr_starred::FormatExprStarred, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_starred::FormatExprStarred::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_name::FormatExprName +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprName, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprName { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprName, + crate::expression::expr_name::FormatExprName, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_name::FormatExprName::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprName { + type Format = FormatOwnedWithRule< + ast::ExprName, + crate::expression::expr_name::FormatExprName, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_name::FormatExprName::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_list::FormatExprList +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprList, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprList { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprList, + crate::expression::expr_list::FormatExprList, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_list::FormatExprList::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprList { + type Format = FormatOwnedWithRule< + ast::ExprList, + crate::expression::expr_list::FormatExprList, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_list::FormatExprList::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_tuple::FormatExprTuple +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprTuple, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprTuple { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprTuple, + crate::expression::expr_tuple::FormatExprTuple, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_tuple::FormatExprTuple::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprTuple { + type Format = FormatOwnedWithRule< + ast::ExprTuple, + crate::expression::expr_tuple::FormatExprTuple, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_tuple::FormatExprTuple::default(), + ) + } +} + +impl FormatRule> + for crate::expression::expr_slice::FormatExprSlice +{ + #[inline] + fn fmt( + &self, + node: &ast::ExprSlice, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExprSlice { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExprSlice, + crate::expression::expr_slice::FormatExprSlice, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::expression::expr_slice::FormatExprSlice::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExprSlice { + type Format = FormatOwnedWithRule< + ast::ExprSlice, + crate::expression::expr_slice::FormatExprSlice, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::expression::expr_slice::FormatExprSlice::default(), + ) + } +} + +impl FormatRule> + for crate::other::excepthandler_except_handler::FormatExcepthandlerExceptHandler +{ + #[inline] + fn fmt( + &self, + node: &ast::ExcepthandlerExceptHandler, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::ExcepthandlerExceptHandler { + type Format<'a> = FormatRefWithRule< + 'a, + ast::ExcepthandlerExceptHandler, + crate::other::excepthandler_except_handler::FormatExcepthandlerExceptHandler, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::other::excepthandler_except_handler::FormatExcepthandlerExceptHandler::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::ExcepthandlerExceptHandler { + type Format = FormatOwnedWithRule< + ast::ExcepthandlerExceptHandler, + crate::other::excepthandler_except_handler::FormatExcepthandlerExceptHandler, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::other::excepthandler_except_handler::FormatExcepthandlerExceptHandler::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_value::FormatPatternMatchValue +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchValue, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchValue { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchValue, + crate::pattern::pattern_match_value::FormatPatternMatchValue, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_value::FormatPatternMatchValue::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchValue { + type Format = FormatOwnedWithRule< + ast::PatternMatchValue, + crate::pattern::pattern_match_value::FormatPatternMatchValue, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_value::FormatPatternMatchValue::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_singleton::FormatPatternMatchSingleton +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchSingleton, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchSingleton { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchSingleton, + crate::pattern::pattern_match_singleton::FormatPatternMatchSingleton, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_singleton::FormatPatternMatchSingleton::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchSingleton { + type Format = FormatOwnedWithRule< + ast::PatternMatchSingleton, + crate::pattern::pattern_match_singleton::FormatPatternMatchSingleton, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_singleton::FormatPatternMatchSingleton::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_sequence::FormatPatternMatchSequence +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchSequence, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchSequence { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchSequence, + crate::pattern::pattern_match_sequence::FormatPatternMatchSequence, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_sequence::FormatPatternMatchSequence::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchSequence { + type Format = FormatOwnedWithRule< + ast::PatternMatchSequence, + crate::pattern::pattern_match_sequence::FormatPatternMatchSequence, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_sequence::FormatPatternMatchSequence::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_mapping::FormatPatternMatchMapping +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchMapping, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchMapping { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchMapping, + crate::pattern::pattern_match_mapping::FormatPatternMatchMapping, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_mapping::FormatPatternMatchMapping::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchMapping { + type Format = FormatOwnedWithRule< + ast::PatternMatchMapping, + crate::pattern::pattern_match_mapping::FormatPatternMatchMapping, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_mapping::FormatPatternMatchMapping::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_class::FormatPatternMatchClass +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchClass, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchClass { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchClass, + crate::pattern::pattern_match_class::FormatPatternMatchClass, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_class::FormatPatternMatchClass::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchClass { + type Format = FormatOwnedWithRule< + ast::PatternMatchClass, + crate::pattern::pattern_match_class::FormatPatternMatchClass, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_class::FormatPatternMatchClass::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_star::FormatPatternMatchStar +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchStar, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchStar { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchStar, + crate::pattern::pattern_match_star::FormatPatternMatchStar, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_star::FormatPatternMatchStar::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchStar { + type Format = FormatOwnedWithRule< + ast::PatternMatchStar, + crate::pattern::pattern_match_star::FormatPatternMatchStar, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_star::FormatPatternMatchStar::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_as::FormatPatternMatchAs +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchAs, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchAs { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchAs, + crate::pattern::pattern_match_as::FormatPatternMatchAs, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_as::FormatPatternMatchAs::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchAs { + type Format = FormatOwnedWithRule< + ast::PatternMatchAs, + crate::pattern::pattern_match_as::FormatPatternMatchAs, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_as::FormatPatternMatchAs::default(), + ) + } +} + +impl FormatRule> + for crate::pattern::pattern_match_or::FormatPatternMatchOr +{ + #[inline] + fn fmt( + &self, + node: &ast::PatternMatchOr, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::PatternMatchOr { + type Format<'a> = FormatRefWithRule< + 'a, + ast::PatternMatchOr, + crate::pattern::pattern_match_or::FormatPatternMatchOr, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::pattern::pattern_match_or::FormatPatternMatchOr::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::PatternMatchOr { + type Format = FormatOwnedWithRule< + ast::PatternMatchOr, + crate::pattern::pattern_match_or::FormatPatternMatchOr, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::pattern::pattern_match_or::FormatPatternMatchOr::default(), + ) + } +} + +impl FormatRule> + for crate::other::type_ignore_type_ignore::FormatTypeIgnoreTypeIgnore +{ + #[inline] + fn fmt( + &self, + node: &ast::TypeIgnoreTypeIgnore, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::TypeIgnoreTypeIgnore { + type Format<'a> = FormatRefWithRule< + 'a, + ast::TypeIgnoreTypeIgnore, + crate::other::type_ignore_type_ignore::FormatTypeIgnoreTypeIgnore, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::other::type_ignore_type_ignore::FormatTypeIgnoreTypeIgnore::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::TypeIgnoreTypeIgnore { + type Format = FormatOwnedWithRule< + ast::TypeIgnoreTypeIgnore, + crate::other::type_ignore_type_ignore::FormatTypeIgnoreTypeIgnore, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::other::type_ignore_type_ignore::FormatTypeIgnoreTypeIgnore::default(), + ) + } +} + +impl FormatRule> + for crate::other::comprehension::FormatComprehension +{ + #[inline] + fn fmt( + &self, + node: &ast::Comprehension, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Comprehension { + type Format<'a> = FormatRefWithRule< + 'a, + ast::Comprehension, + crate::other::comprehension::FormatComprehension, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::other::comprehension::FormatComprehension::default(), + ) + } +} +impl<'ast> IntoFormat> for ast::Comprehension { + type Format = FormatOwnedWithRule< + ast::Comprehension, + crate::other::comprehension::FormatComprehension, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::other::comprehension::FormatComprehension::default(), + ) + } +} + +impl FormatRule> for crate::other::arguments::FormatArguments { + #[inline] + fn fmt( + &self, + node: &ast::Arguments, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Arguments { + type Format<'a> = FormatRefWithRule< + 'a, + ast::Arguments, + crate::other::arguments::FormatArguments, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::arguments::FormatArguments::default()) + } +} +impl<'ast> IntoFormat> for ast::Arguments { + type Format = FormatOwnedWithRule< + ast::Arguments, + crate::other::arguments::FormatArguments, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::arguments::FormatArguments::default()) + } +} + +impl FormatRule> for crate::other::arg::FormatArg { + #[inline] + fn fmt(&self, node: &ast::Arg, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Arg { + type Format<'a> = + FormatRefWithRule<'a, ast::Arg, crate::other::arg::FormatArg, PyFormatContext<'ast>>; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::arg::FormatArg::default()) + } +} +impl<'ast> IntoFormat> for ast::Arg { + type Format = + FormatOwnedWithRule>; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::arg::FormatArg::default()) + } +} + +impl FormatRule> for crate::other::keyword::FormatKeyword { + #[inline] + fn fmt(&self, node: &ast::Keyword, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Keyword { + type Format<'a> = FormatRefWithRule< + 'a, + ast::Keyword, + crate::other::keyword::FormatKeyword, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::keyword::FormatKeyword::default()) + } +} +impl<'ast> IntoFormat> for ast::Keyword { + type Format = FormatOwnedWithRule< + ast::Keyword, + crate::other::keyword::FormatKeyword, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::keyword::FormatKeyword::default()) + } +} + +impl FormatRule> for crate::other::alias::FormatAlias { + #[inline] + fn fmt(&self, node: &ast::Alias, f: &mut Formatter>) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Alias { + type Format<'a> = + FormatRefWithRule<'a, ast::Alias, crate::other::alias::FormatAlias, PyFormatContext<'ast>>; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::alias::FormatAlias::default()) + } +} +impl<'ast> IntoFormat> for ast::Alias { + type Format = + FormatOwnedWithRule>; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::alias::FormatAlias::default()) + } +} + +impl FormatRule> for crate::other::withitem::FormatWithitem { + #[inline] + fn fmt( + &self, + node: &ast::Withitem, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::Withitem { + type Format<'a> = FormatRefWithRule< + 'a, + ast::Withitem, + crate::other::withitem::FormatWithitem, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::withitem::FormatWithitem::default()) + } +} +impl<'ast> IntoFormat> for ast::Withitem { + type Format = FormatOwnedWithRule< + ast::Withitem, + crate::other::withitem::FormatWithitem, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::withitem::FormatWithitem::default()) + } +} + +impl FormatRule> for crate::other::match_case::FormatMatchCase { + #[inline] + fn fmt( + &self, + node: &ast::MatchCase, + f: &mut Formatter>, + ) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl<'ast> AsFormat> for ast::MatchCase { + type Format<'a> = FormatRefWithRule< + 'a, + ast::MatchCase, + crate::other::match_case::FormatMatchCase, + PyFormatContext<'ast>, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new(self, crate::other::match_case::FormatMatchCase::default()) + } +} +impl<'ast> IntoFormat> for ast::MatchCase { + type Format = FormatOwnedWithRule< + ast::MatchCase, + crate::other::match_case::FormatMatchCase, + PyFormatContext<'ast>, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new(self, crate::other::match_case::FormatMatchCase::default()) + } +} diff --git a/crates/ruff_python_formatter/src/lib.rs b/crates/ruff_python_formatter/src/lib.rs index 0983557c90..bc51573a36 100644 --- a/crates/ruff_python_formatter/src/lib.rs +++ b/crates/ruff_python_formatter/src/lib.rs @@ -3,23 +3,86 @@ use rustpython_parser::ast::Mod; use rustpython_parser::lexer::lex; use rustpython_parser::{parse_tokens, Mode}; +use ruff_formatter::formatter::Formatter; +use ruff_formatter::prelude::source_position; use ruff_formatter::{ - format, FormatResult, Formatted, IndentStyle, Printed, SimpleFormatOptions, SourceCode, + format, write, Buffer, FormatResult, Formatted, IndentStyle, Printed, SimpleFormatOptions, + SourceCode, }; +use ruff_python_ast::node::AstNode; use ruff_python_ast::source_code::{CommentRanges, CommentRangesBuilder, Locator}; use crate::comments::Comments; -use crate::context::ASTFormatContext; +use crate::context::PyFormatContext; use crate::module::FormatModule; pub mod cli; mod comments; -pub mod context; -mod module; +pub(crate) mod context; +pub(crate) mod expression; +mod generated; +pub(crate) mod module; +pub(crate) mod other; +pub(crate) mod pattern; mod prelude; +pub(crate) mod statement; include!("../../ruff_formatter/shared_traits.rs"); +pub(crate) type PyFormatter<'buf, 'ast> = Formatter<'buf, PyFormatContext<'ast>>; + +/// Rule for formatting a JavaScript [`AstNode`]. +pub(crate) trait FormatNodeRule +where + N: AstNode, +{ + fn fmt(&self, node: &N, f: &mut PyFormatter) -> FormatResult<()> { + write!(f, [source_position(node.start())])?; + self.fmt_leading_comments(node, f)?; + self.fmt_node(node, f)?; + self.fmt_dangling_comments(node, f)?; + self.fmt_trailing_comments(node, f)?; + write!(f, [source_position(node.start())]) + } + + /// Formats the node without comments. Ignores any suppression comments. + fn fmt_node(&self, node: &N, f: &mut PyFormatter) -> FormatResult<()> { + self.fmt_fields(node, f)?; + + Ok(()) + } + + /// Formats the node's fields. + fn fmt_fields(&self, item: &N, f: &mut PyFormatter) -> FormatResult<()>; + + /// Formats the [leading comments](crate::comments#leading-comments) of the node. + /// + /// You may want to override this method if you want to manually handle the formatting of comments + /// inside of the `fmt_fields` method or customize the formatting of the leading comments. + fn fmt_leading_comments(&self, _node: &N, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } + + /// Formats the [dangling comments](rome_formatter::comments#dangling-comments) of the node. + /// + /// You should override this method if the node handled by this rule can have dangling comments because the + /// default implementation formats the dangling comments at the end of the node, which isn't ideal but ensures that + /// no comments are dropped. + /// + /// A node can have dangling comments if all its children are tokens or if all node childrens are optional. + fn fmt_dangling_comments(&self, _node: &N, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } + + /// Formats the [trailing comments](rome_formatter::comments#trailing-comments) of the node. + /// + /// You may want to override this method if you want to manually handle the formatting of comments + /// inside of the `fmt_fields` method or customize the formatting of the trailing comments. + fn fmt_trailing_comments(&self, _node: &N, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} + pub fn format_module(contents: &str) -> Result { // Tokenize once let mut tokens = Vec::new(); @@ -52,13 +115,13 @@ pub fn format_node<'a>( root: &'a Mod, comment_ranges: &'a CommentRanges, source: &'a str, -) -> FormatResult>> { +) -> FormatResult>> { let comments = Comments::from_ast(root, SourceCode::new(source), comment_ranges); let locator = Locator::new(source); format!( - ASTFormatContext::new( + PyFormatContext::new( SimpleFormatOptions { indent_style: IndentStyle::Space(4), line_width: 88.try_into().unwrap(), diff --git a/crates/ruff_python_formatter/src/module/mod.rs b/crates/ruff_python_formatter/src/module/mod.rs index 694414d0fb..ce3fc5e8ac 100644 --- a/crates/ruff_python_formatter/src/module/mod.rs +++ b/crates/ruff_python_formatter/src/module/mod.rs @@ -1,4 +1,9 @@ -use crate::context::ASTFormatContext; +pub(crate) mod mod_expression; +pub(crate) mod mod_function_type; +pub(crate) mod mod_interactive; +pub(crate) mod mod_module; + +use crate::context::PyFormatContext; use ruff_formatter::format_element::tag::VerbatimKind; use ruff_formatter::prelude::*; use ruff_formatter::write; @@ -14,8 +19,8 @@ impl<'a> FormatModule<'a> { } } -impl Format> for FormatModule<'_> { - fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { +impl Format> for FormatModule<'_> { + fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { let range = self.module.range(); write!(f, [source_position(range.start())])?; diff --git a/crates/ruff_python_formatter/src/module/mod_expression.rs b/crates/ruff_python_formatter/src/module/mod_expression.rs new file mode 100644 index 0000000000..73ab6211fb --- /dev/null +++ b/crates/ruff_python_formatter/src/module/mod_expression.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ModExpression; + +#[derive(Default)] +pub struct FormatModExpression; + +impl FormatNodeRule for FormatModExpression { + fn fmt_fields(&self, _item: &ModExpression, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/module/mod_function_type.rs b/crates/ruff_python_formatter/src/module/mod_function_type.rs new file mode 100644 index 0000000000..5dced49b0f --- /dev/null +++ b/crates/ruff_python_formatter/src/module/mod_function_type.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ModFunctionType; + +#[derive(Default)] +pub struct FormatModFunctionType; + +impl FormatNodeRule for FormatModFunctionType { + fn fmt_fields(&self, _item: &ModFunctionType, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/module/mod_interactive.rs b/crates/ruff_python_formatter/src/module/mod_interactive.rs new file mode 100644 index 0000000000..3dd3b3e4c6 --- /dev/null +++ b/crates/ruff_python_formatter/src/module/mod_interactive.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ModInteractive; + +#[derive(Default)] +pub struct FormatModInteractive; + +impl FormatNodeRule for FormatModInteractive { + fn fmt_fields(&self, _item: &ModInteractive, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/module/mod_module.rs b/crates/ruff_python_formatter/src/module/mod_module.rs new file mode 100644 index 0000000000..6e8fadaf41 --- /dev/null +++ b/crates/ruff_python_formatter/src/module/mod_module.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ModModule; + +#[derive(Default)] +pub struct FormatModModule; + +impl FormatNodeRule for FormatModModule { + fn fmt_fields(&self, _item: &ModModule, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/alias.rs b/crates/ruff_python_formatter/src/other/alias.rs new file mode 100644 index 0000000000..04187409b2 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/alias.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Alias; + +#[derive(Default)] +pub struct FormatAlias; + +impl FormatNodeRule for FormatAlias { + fn fmt_fields(&self, _item: &Alias, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/arg.rs b/crates/ruff_python_formatter/src/other/arg.rs new file mode 100644 index 0000000000..933468c9e8 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/arg.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Arg; + +#[derive(Default)] +pub struct FormatArg; + +impl FormatNodeRule for FormatArg { + fn fmt_fields(&self, _item: &Arg, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/arguments.rs b/crates/ruff_python_formatter/src/other/arguments.rs new file mode 100644 index 0000000000..2136308466 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/arguments.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Arguments; + +#[derive(Default)] +pub struct FormatArguments; + +impl FormatNodeRule for FormatArguments { + fn fmt_fields(&self, _item: &Arguments, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/comprehension.rs b/crates/ruff_python_formatter/src/other/comprehension.rs new file mode 100644 index 0000000000..2d8324c8d7 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/comprehension.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Comprehension; + +#[derive(Default)] +pub struct FormatComprehension; + +impl FormatNodeRule for FormatComprehension { + fn fmt_fields(&self, _item: &Comprehension, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/excepthandler_except_handler.rs b/crates/ruff_python_formatter/src/other/excepthandler_except_handler.rs new file mode 100644 index 0000000000..cc1b78889d --- /dev/null +++ b/crates/ruff_python_formatter/src/other/excepthandler_except_handler.rs @@ -0,0 +1,16 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::ExcepthandlerExceptHandler; + +#[derive(Default)] +pub struct FormatExcepthandlerExceptHandler; + +impl FormatNodeRule for FormatExcepthandlerExceptHandler { + fn fmt_fields( + &self, + _item: &ExcepthandlerExceptHandler, + _f: &mut PyFormatter, + ) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/keyword.rs b/crates/ruff_python_formatter/src/other/keyword.rs new file mode 100644 index 0000000000..ade4d731b1 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/keyword.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Keyword; + +#[derive(Default)] +pub struct FormatKeyword; + +impl FormatNodeRule for FormatKeyword { + fn fmt_fields(&self, _item: &Keyword, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/match_case.rs b/crates/ruff_python_formatter/src/other/match_case.rs new file mode 100644 index 0000000000..a3e3d134d9 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/match_case.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::MatchCase; + +#[derive(Default)] +pub struct FormatMatchCase; + +impl FormatNodeRule for FormatMatchCase { + fn fmt_fields(&self, _item: &MatchCase, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/mod.rs b/crates/ruff_python_formatter/src/other/mod.rs new file mode 100644 index 0000000000..3ca3d592d2 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/mod.rs @@ -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; diff --git a/crates/ruff_python_formatter/src/other/type_ignore_type_ignore.rs b/crates/ruff_python_formatter/src/other/type_ignore_type_ignore.rs new file mode 100644 index 0000000000..bb493395a6 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/type_ignore_type_ignore.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::TypeIgnoreTypeIgnore; + +#[derive(Default)] +pub struct FormatTypeIgnoreTypeIgnore; + +impl FormatNodeRule for FormatTypeIgnoreTypeIgnore { + fn fmt_fields(&self, _item: &TypeIgnoreTypeIgnore, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/other/withitem.rs b/crates/ruff_python_formatter/src/other/withitem.rs new file mode 100644 index 0000000000..145b4a72d9 --- /dev/null +++ b/crates/ruff_python_formatter/src/other/withitem.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::Withitem; + +#[derive(Default)] +pub struct FormatWithitem; + +impl FormatNodeRule for FormatWithitem { + fn fmt_fields(&self, _item: &Withitem, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/mod.rs b/crates/ruff_python_formatter/src/pattern/mod.rs new file mode 100644 index 0000000000..992f90a49d --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/mod.rs @@ -0,0 +1,8 @@ +pub(crate) mod pattern_match_as; +pub(crate) mod pattern_match_class; +pub(crate) mod pattern_match_mapping; +pub(crate) mod pattern_match_or; +pub(crate) mod pattern_match_sequence; +pub(crate) mod pattern_match_singleton; +pub(crate) mod pattern_match_star; +pub(crate) mod pattern_match_value; diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs new file mode 100644 index 0000000000..c9508a4e1f --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_as.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchAs; + +#[derive(Default)] +pub struct FormatPatternMatchAs; + +impl FormatNodeRule for FormatPatternMatchAs { + fn fmt_fields(&self, _item: &PatternMatchAs, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs new file mode 100644 index 0000000000..897e1797de --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_class.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchClass; + +#[derive(Default)] +pub struct FormatPatternMatchClass; + +impl FormatNodeRule for FormatPatternMatchClass { + fn fmt_fields(&self, _item: &PatternMatchClass, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs new file mode 100644 index 0000000000..8f6ba2caf4 --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchMapping; + +#[derive(Default)] +pub struct FormatPatternMatchMapping; + +impl FormatNodeRule for FormatPatternMatchMapping { + fn fmt_fields(&self, _item: &PatternMatchMapping, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs new file mode 100644 index 0000000000..5b2dcaa63c --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_or.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchOr; + +#[derive(Default)] +pub struct FormatPatternMatchOr; + +impl FormatNodeRule for FormatPatternMatchOr { + fn fmt_fields(&self, _item: &PatternMatchOr, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs new file mode 100644 index 0000000000..41c2b39545 --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchSequence; + +#[derive(Default)] +pub struct FormatPatternMatchSequence; + +impl FormatNodeRule for FormatPatternMatchSequence { + fn fmt_fields(&self, _item: &PatternMatchSequence, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs new file mode 100644 index 0000000000..b01f04a12f --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_singleton.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchSingleton; + +#[derive(Default)] +pub struct FormatPatternMatchSingleton; + +impl FormatNodeRule for FormatPatternMatchSingleton { + fn fmt_fields(&self, _item: &PatternMatchSingleton, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs new file mode 100644 index 0000000000..2a5f621a22 --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_star.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchStar; + +#[derive(Default)] +pub struct FormatPatternMatchStar; + +impl FormatNodeRule for FormatPatternMatchStar { + fn fmt_fields(&self, _item: &PatternMatchStar, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_value.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_value.rs new file mode 100644 index 0000000000..72afeaa89e --- /dev/null +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_value.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::PatternMatchValue; + +#[derive(Default)] +pub struct FormatPatternMatchValue; + +impl FormatNodeRule for FormatPatternMatchValue { + fn fmt_fields(&self, _item: &PatternMatchValue, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/prelude.rs b/crates/ruff_python_formatter/src/prelude.rs index b85bb97b21..2f532e2999 100644 --- a/crates/ruff_python_formatter/src/prelude.rs +++ b/crates/ruff_python_formatter/src/prelude.rs @@ -1,4 +1,4 @@ #[allow(unused_imports)] -pub(crate) use crate::{ASTFormatContext, AsFormat, FormattedIterExt as _, IntoFormat}; +pub(crate) use crate::{AsFormat, FormattedIterExt as _, IntoFormat, PyFormatContext}; #[allow(unused_imports)] pub(crate) use ruff_formatter::prelude::*; diff --git a/crates/ruff_python_formatter/src/statement/mod.rs b/crates/ruff_python_formatter/src/statement/mod.rs new file mode 100644 index 0000000000..13bf2372ad --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/mod.rs @@ -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; diff --git a/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs new file mode 100644 index 0000000000..90bd9c6ab8 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAnnAssign; + +#[derive(Default)] +pub struct FormatStmtAnnAssign; + +impl FormatNodeRule for FormatStmtAnnAssign { + fn fmt_fields(&self, _item: &StmtAnnAssign, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_assert.rs b/crates/ruff_python_formatter/src/statement/stmt_assert.rs new file mode 100644 index 0000000000..274260b3af --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_assert.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAssert; + +#[derive(Default)] +pub struct FormatStmtAssert; + +impl FormatNodeRule for FormatStmtAssert { + fn fmt_fields(&self, _item: &StmtAssert, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_assign.rs new file mode 100644 index 0000000000..a24d2cb561 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_assign.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAssign; + +#[derive(Default)] +pub struct FormatStmtAssign; + +impl FormatNodeRule for FormatStmtAssign { + fn fmt_fields(&self, _item: &StmtAssign, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_async_for.rs b/crates/ruff_python_formatter/src/statement/stmt_async_for.rs new file mode 100644 index 0000000000..d83d8314cf --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_async_for.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAsyncFor; + +#[derive(Default)] +pub struct FormatStmtAsyncFor; + +impl FormatNodeRule for FormatStmtAsyncFor { + fn fmt_fields(&self, _item: &StmtAsyncFor, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_async_function_def.rs b/crates/ruff_python_formatter/src/statement/stmt_async_function_def.rs new file mode 100644 index 0000000000..15dff5ba19 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_async_function_def.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAsyncFunctionDef; + +#[derive(Default)] +pub struct FormatStmtAsyncFunctionDef; + +impl FormatNodeRule for FormatStmtAsyncFunctionDef { + fn fmt_fields(&self, _item: &StmtAsyncFunctionDef, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_async_with.rs b/crates/ruff_python_formatter/src/statement/stmt_async_with.rs new file mode 100644 index 0000000000..16ebedea9f --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_async_with.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAsyncWith; + +#[derive(Default)] +pub struct FormatStmtAsyncWith; + +impl FormatNodeRule for FormatStmtAsyncWith { + fn fmt_fields(&self, _item: &StmtAsyncWith, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs b/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs new file mode 100644 index 0000000000..2574262504 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtAugAssign; + +#[derive(Default)] +pub struct FormatStmtAugAssign; + +impl FormatNodeRule for FormatStmtAugAssign { + fn fmt_fields(&self, _item: &StmtAugAssign, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_break.rs b/crates/ruff_python_formatter/src/statement/stmt_break.rs new file mode 100644 index 0000000000..1e1b600166 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_break.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtBreak; + +#[derive(Default)] +pub struct FormatStmtBreak; + +impl FormatNodeRule for FormatStmtBreak { + fn fmt_fields(&self, _item: &StmtBreak, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs new file mode 100644 index 0000000000..c08da73bde --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtClassDef; + +#[derive(Default)] +pub struct FormatStmtClassDef; + +impl FormatNodeRule for FormatStmtClassDef { + fn fmt_fields(&self, _item: &StmtClassDef, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_continue.rs b/crates/ruff_python_formatter/src/statement/stmt_continue.rs new file mode 100644 index 0000000000..7f684c9f0f --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_continue.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::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<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_delete.rs b/crates/ruff_python_formatter/src/statement/stmt_delete.rs new file mode 100644 index 0000000000..8ada8b86ec --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_delete.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtDelete; + +#[derive(Default)] +pub struct FormatStmtDelete; + +impl FormatNodeRule for FormatStmtDelete { + fn fmt_fields(&self, _item: &StmtDelete, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_expr.rs b/crates/ruff_python_formatter/src/statement/stmt_expr.rs new file mode 100644 index 0000000000..03952de865 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_expr.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtExpr; + +#[derive(Default)] +pub struct FormatStmtExpr; + +impl FormatNodeRule for FormatStmtExpr { + fn fmt_fields(&self, _item: &StmtExpr, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_for.rs b/crates/ruff_python_formatter/src/statement/stmt_for.rs new file mode 100644 index 0000000000..57d50fbe4d --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_for.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtFor; + +#[derive(Default)] +pub struct FormatStmtFor; + +impl FormatNodeRule for FormatStmtFor { + fn fmt_fields(&self, _item: &StmtFor, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs new file mode 100644 index 0000000000..153014b411 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtFunctionDef; + +#[derive(Default)] +pub struct FormatStmtFunctionDef; + +impl FormatNodeRule for FormatStmtFunctionDef { + fn fmt_fields(&self, _item: &StmtFunctionDef, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_global.rs b/crates/ruff_python_formatter/src/statement/stmt_global.rs new file mode 100644 index 0000000000..ee3ced3b32 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_global.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtGlobal; + +#[derive(Default)] +pub struct FormatStmtGlobal; + +impl FormatNodeRule for FormatStmtGlobal { + fn fmt_fields(&self, _item: &StmtGlobal, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_if.rs b/crates/ruff_python_formatter/src/statement/stmt_if.rs new file mode 100644 index 0000000000..788ed54266 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_if.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtIf; + +#[derive(Default)] +pub struct FormatStmtIf; + +impl FormatNodeRule for FormatStmtIf { + fn fmt_fields(&self, _item: &StmtIf, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_import.rs b/crates/ruff_python_formatter/src/statement/stmt_import.rs new file mode 100644 index 0000000000..3bfd9e8048 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_import.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtImport; + +#[derive(Default)] +pub struct FormatStmtImport; + +impl FormatNodeRule for FormatStmtImport { + fn fmt_fields(&self, _item: &StmtImport, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs new file mode 100644 index 0000000000..ab33945941 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtImportFrom; + +#[derive(Default)] +pub struct FormatStmtImportFrom; + +impl FormatNodeRule for FormatStmtImportFrom { + fn fmt_fields(&self, _item: &StmtImportFrom, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_match.rs b/crates/ruff_python_formatter/src/statement/stmt_match.rs new file mode 100644 index 0000000000..d2b2e12d48 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_match.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtMatch; + +#[derive(Default)] +pub struct FormatStmtMatch; + +impl FormatNodeRule for FormatStmtMatch { + fn fmt_fields(&self, _item: &StmtMatch, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs b/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs new file mode 100644 index 0000000000..33a9cabda3 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtNonlocal; + +#[derive(Default)] +pub struct FormatStmtNonlocal; + +impl FormatNodeRule for FormatStmtNonlocal { + fn fmt_fields(&self, _item: &StmtNonlocal, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_pass.rs b/crates/ruff_python_formatter/src/statement/stmt_pass.rs new file mode 100644 index 0000000000..edc11dca8c --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_pass.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtPass; + +#[derive(Default)] +pub struct FormatStmtPass; + +impl FormatNodeRule for FormatStmtPass { + fn fmt_fields(&self, _item: &StmtPass, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_raise.rs b/crates/ruff_python_formatter/src/statement/stmt_raise.rs new file mode 100644 index 0000000000..433eacb4db --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_raise.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtRaise; + +#[derive(Default)] +pub struct FormatStmtRaise; + +impl FormatNodeRule for FormatStmtRaise { + fn fmt_fields(&self, _item: &StmtRaise, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_return.rs b/crates/ruff_python_formatter/src/statement/stmt_return.rs new file mode 100644 index 0000000000..0cd6790cd5 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_return.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtReturn; + +#[derive(Default)] +pub struct FormatStmtReturn; + +impl FormatNodeRule for FormatStmtReturn { + fn fmt_fields(&self, _item: &StmtReturn, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_try.rs b/crates/ruff_python_formatter/src/statement/stmt_try.rs new file mode 100644 index 0000000000..84bdec3b6e --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_try.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtTry; + +#[derive(Default)] +pub struct FormatStmtTry; + +impl FormatNodeRule for FormatStmtTry { + fn fmt_fields(&self, _item: &StmtTry, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_try_star.rs b/crates/ruff_python_formatter/src/statement/stmt_try_star.rs new file mode 100644 index 0000000000..4080bf9349 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_try_star.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtTryStar; + +#[derive(Default)] +pub struct FormatStmtTryStar; + +impl FormatNodeRule for FormatStmtTryStar { + fn fmt_fields(&self, _item: &StmtTryStar, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_while.rs b/crates/ruff_python_formatter/src/statement/stmt_while.rs new file mode 100644 index 0000000000..157f69fb26 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_while.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtWhile; + +#[derive(Default)] +pub struct FormatStmtWhile; + +impl FormatNodeRule for FormatStmtWhile { + fn fmt_fields(&self, _item: &StmtWhile, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +} diff --git a/crates/ruff_python_formatter/src/statement/stmt_with.rs b/crates/ruff_python_formatter/src/statement/stmt_with.rs new file mode 100644 index 0000000000..f0d1c26735 --- /dev/null +++ b/crates/ruff_python_formatter/src/statement/stmt_with.rs @@ -0,0 +1,12 @@ +use crate::{FormatNodeRule, PyFormatter}; +use ruff_formatter::FormatResult; +use rustpython_parser::ast::StmtWith; + +#[derive(Default)] +pub struct FormatStmtWith; + +impl FormatNodeRule for FormatStmtWith { + fn fmt_fields(&self, _item: &StmtWith, _f: &mut PyFormatter) -> FormatResult<()> { + Ok(()) + } +}