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,9 +1,3 @@
use crate::comments::{
leading_alternate_branch_comments, trailing_comments, SourceComment, SuppressionKind,
};
use crate::prelude::*;
use crate::statement::suite::{contains_only_an_ellipsis, SuiteKind};
use crate::verbatim::write_suppressed_clause_header;
use ruff_formatter::{write, Argument, Arguments, FormatError};
use ruff_python_ast::node::AnyNodeRef;
use ruff_python_ast::{
@ -13,6 +7,13 @@ use ruff_python_ast::{
use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer};
use ruff_text_size::{TextRange, TextSize};
use crate::comments::{
leading_alternate_branch_comments, trailing_comments, SourceComment, SuppressionKind,
};
use crate::prelude::*;
use crate::statement::suite::{contains_only_an_ellipsis, SuiteKind};
use crate::verbatim::write_suppressed_clause_header;
/// The header of a compound statement clause.
///
/// > A compound statement consists of one or more clauses. A clause consists of a header and a suite.

View file

@ -1,10 +1,10 @@
use ruff_formatter::write;
use ruff_python_ast::StmtAnnAssign;
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::StmtAnnAssign;
#[derive(Default)]
pub struct FormatStmtAnnAssign;

View file

@ -1,11 +1,12 @@
use ruff_formatter::prelude::{space, text};
use ruff_formatter::write;
use ruff_python_ast::StmtAssert;
use crate::comments::{SourceComment, SuppressionKind};
use crate::context::PyFormatContext;
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::{FormatNodeRule, PyFormatter};
use ruff_formatter::prelude::{space, text};
use ruff_formatter::{write, Buffer, FormatResult};
use ruff_python_ast::StmtAssert;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatStmtAssert;

View file

@ -1,12 +1,11 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_formatter::{format_args, write, FormatError};
use ruff_python_ast::{Expr, StmtAssign};
use crate::comments::{SourceComment, SuppressionKind};
use crate::context::{NodeLevel, WithNodeLevel};
use crate::expression::parentheses::{Parentheses, Parenthesize};
use crate::expression::{has_own_parentheses, maybe_parenthesize_expression};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtAssign;

View file

@ -2,7 +2,6 @@ use ruff_python_ast::StmtBreak;
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtBreak;

View file

@ -4,10 +4,8 @@ use ruff_python_trivia::lines_after_ignoring_trivia;
use crate::comments::{leading_comments, trailing_comments, SourceComment};
use crate::prelude::*;
use crate::statement::suite::SuiteKind;
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::FormatNodeRule;
use crate::statement::suite::SuiteKind;
#[derive(Default)]
pub struct FormatStmtClassDef;

View file

@ -1,8 +1,7 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_python_ast::StmtContinue;
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtContinue;

View file

@ -6,7 +6,6 @@ use crate::comments::{dangling_node_comments, SourceComment, SuppressionKind};
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtDelete;

View file

@ -1,11 +1,10 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_python_ast as ast;
use ruff_python_ast::{Expr, Operator, StmtExpr};
use crate::comments::{SourceComment, SuppressionKind};
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtExpr;

View file

@ -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, ElseClause};
use crate::FormatNodeRule;
#[derive(Debug)]
struct ExprTupleWithoutParentheses<'a>(&'a Expr);

View file

@ -9,7 +9,6 @@ use crate::prelude::*;
use crate::statement::clause::{clause_body, clause_header, ClauseHeader};
use crate::statement::stmt_class_def::FormatDecorators;
use crate::statement::suite::SuiteKind;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtFunctionDef;

View file

@ -1,10 +1,9 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_formatter::{format_args, write};
use ruff_python_ast::node::AstNode;
use ruff_python_ast::StmtGlobal;
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtGlobal;

View file

@ -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;
#[derive(Default)]
pub struct FormatStmtIf;

View file

@ -1,9 +1,8 @@
use crate::prelude::*;
use ruff_formatter::{format_args, write};
use ruff_python_ast::StmtImport;
use crate::comments::{SourceComment, SuppressionKind};
use crate::FormatNodeRule;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatStmtImport;

View file

@ -6,7 +6,6 @@ use crate::builders::{parenthesize_if_expands, PyFormatterExtensions, TrailingCo
use crate::comments::{SourceComment, SuppressionKind};
use crate::expression::parentheses::parenthesized;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtImportFrom;

View file

@ -1,6 +1,7 @@
use ruff_python_ast::{Ranged, StmtIpyEscapeCommand};
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use ruff_python_ast::{Ranged, StmtIpyEscapeCommand};
#[derive(Default)]
pub struct FormatStmtIpyEscapeCommand;

View file

@ -7,7 +7,6 @@ use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::statement::clause::{clause_header, ClauseHeader};
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtMatch;

View file

@ -1,10 +1,9 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_formatter::{format_args, write};
use ruff_python_ast::node::AstNode;
use ruff_python_ast::StmtNonlocal;
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtNonlocal;

View file

@ -1,8 +1,7 @@
use crate::comments::{SourceComment, SuppressionKind};
use ruff_python_ast::StmtPass;
use crate::comments::{SourceComment, SuppressionKind};
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtPass;

View file

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

View file

@ -5,7 +5,6 @@ use crate::comments::{SourceComment, SuppressionKind};
use crate::expression::maybe_parenthesize_expression;
use crate::expression::parentheses::Parenthesize;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtReturn;

View file

@ -8,7 +8,6 @@ use crate::other::except_handler_except_handler::ExceptHandlerKind;
use crate::prelude::*;
use crate::statement::clause::{clause_body, clause_header, ClauseHeader, ElseClause};
use crate::statement::{FormatRefWithRule, Stmt};
use crate::{FormatNodeRule, PyFormatter};
#[derive(Default)]
pub struct FormatStmtTry;

View file

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

View file

@ -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, ElseClause};
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatStmtWhile;

View file

@ -1,4 +1,3 @@
use crate::comments::{leading_comments, trailing_comments, Comments};
use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions};
use ruff_python_ast::helpers::is_compound_statement;
use ruff_python_ast::node::AnyNodeRef;
@ -6,6 +5,7 @@ use ruff_python_ast::{self as ast, Constant, Expr, ExprConstant, Ranged, Stmt, S
use ruff_python_trivia::{lines_after_ignoring_trivia, lines_before};
use ruff_text_size::TextRange;
use crate::comments::{leading_comments, trailing_comments, Comments};
use crate::context::{NodeLevel, WithNodeLevel};
use crate::expression::expr_constant::ExprConstantLayout;
use crate::expression::string::StringLayout;