Use the formatter prelude in more files (#6882)

Removes a bunch of imports that are made redundant by the prelude.
This commit is contained in:
Charlie Marsh 2023-08-25 16:51:07 -04:00 committed by GitHub
parent 91a780c771
commit edb9b0c62a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 139 additions and 230 deletions

View file

@ -1,8 +1,8 @@
use crate::{AsFormat, FormatNodeRule, PyFormatter};
use ruff_formatter::prelude::{space, text};
use ruff_formatter::{write, Buffer, Format, FormatResult};
use ruff_formatter::write;
use ruff_python_ast::Alias;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatAlias;

View file

@ -1,14 +1,13 @@
use crate::comments::SourceComment;
use ruff_formatter::write;
use ruff_python_ast::node::AstNode;
use ruff_python_ast::{Arguments, Expr, Ranged};
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
use ruff_text_size::{TextRange, TextSize};
use crate::comments::SourceComment;
use crate::expression::expr_generator_exp::GeneratorExpParentheses;
use crate::expression::parentheses::{empty_parenthesized, parenthesized, Parentheses};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatArguments;

View file

@ -1,10 +1,9 @@
use ruff_formatter::{format_args, write, Buffer, FormatResult};
use ruff_python_ast::{Comprehension, Expr, Ranged};
use crate::comments::{leading_comments, trailing_comments, SourceComment};
use crate::expression::expr_tuple::TupleParentheses;
use crate::prelude::*;
use crate::AsFormat;
use crate::{FormatNodeRule, PyFormatter};
use ruff_formatter::{format_args, write, Buffer, FormatResult};
use ruff_python_ast::{Comprehension, Expr, Ranged};
#[derive(Default)]
pub struct FormatComprehension;

View file

@ -1,10 +1,10 @@
use ruff_formatter::write;
use ruff_python_ast::Decorator;
use crate::comments::{SourceComment, SuppressionKind};
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::FormatNodeRule;
use ruff_formatter::write;
use ruff_python_ast::Decorator;
#[derive(Default)]
pub struct FormatDecorator;

View file

@ -1,8 +1,8 @@
use crate::statement::stmt_if::format_elif_else_clause;
use crate::{FormatNodeRule, PyFormatter};
use ruff_formatter::FormatResult;
use ruff_python_ast::ElifElseClause;
use crate::prelude::*;
use crate::statement::stmt_if::format_elif_else_clause;
/// Note that this implementation misses the leading newlines before the leading comments because
/// it does not have access to the last node of the previous branch. The `StmtIf` therefore doesn't
/// call this but `format_elif_else_clause` directly.

View file

@ -1,5 +1,5 @@
use ruff_formatter::write;
use ruff_formatter::FormatRuleWithOptions;
use ruff_formatter::{write, Buffer, FormatResult};
use ruff_python_ast::ExceptHandlerExceptHandler;
use crate::comments::SourceComment;
@ -7,7 +7,6 @@ use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::{FormatNodeRule, PyFormatter};
#[derive(Copy, Clone, Default)]
pub enum ExceptHandlerKind {

View file

@ -1,5 +1,5 @@
use crate::prelude::*;
use crate::AsFormat;
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule};
use ruff_python_ast::{Identifier, Ranged};

View file

@ -1,8 +1,8 @@
use crate::prelude::*;
use crate::FormatNodeRule;
use ruff_formatter::write;
use ruff_python_ast::Keyword;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatKeyword;

View file

@ -1,4 +1,4 @@
use ruff_formatter::{write, Buffer, FormatResult};
use ruff_formatter::write;
use ruff_python_ast::node::AstNode;
use ruff_python_ast::MatchCase;
@ -7,7 +7,6 @@ use crate::comments::SourceComment;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, Parentheses};
use crate::prelude::*;
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::{FormatNodeRule, PyFormatter};
#[derive(Default)]
pub struct FormatMatchCase;

View file

@ -1,8 +1,8 @@
use crate::prelude::*;
use crate::FormatNodeRule;
use ruff_formatter::write;
use ruff_python_ast::Parameter;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatParameter;

View file

@ -2,7 +2,6 @@ use ruff_formatter::write;
use ruff_python_ast::ParameterWithDefault;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatParameterWithDefault;

View file

@ -13,7 +13,6 @@ use crate::comments::{
use crate::context::{NodeLevel, WithNodeLevel};
use crate::expression::parentheses::empty_parenthesized;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum ParametersParentheses {

View file

@ -1,11 +1,10 @@
use ruff_formatter::{write, Buffer, FormatResult};
use ruff_formatter::write;
use ruff_python_ast::WithItem;
use crate::comments::SourceComment;
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::{parenthesized, Parentheses, Parenthesize};
use crate::prelude::*;
use crate::{FormatNodeRule, PyFormatter};
#[derive(Default)]
pub struct FormatWithItem;