mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-10 10:22:14 +00:00
Switch to Rust 2024 edition (#18129)
This commit is contained in:
parent
e67b35743a
commit
9ae698fe30
1082 changed files with 4211 additions and 3300 deletions
|
@ -11,14 +11,14 @@ use ruff_python_trivia::CommentRanges;
|
|||
use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::comments::{leading_comments, trailing_comments, Comments, SourceComment};
|
||||
use crate::comments::{Comments, SourceComment, leading_comments, trailing_comments};
|
||||
use crate::expression::OperatorPrecedence;
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, in_parentheses_only_if_group_breaks,
|
||||
Parentheses, in_parentheses_only_group, in_parentheses_only_if_group_breaks,
|
||||
in_parentheses_only_soft_line_break, in_parentheses_only_soft_line_break_or_space,
|
||||
is_expression_parenthesized, write_in_parentheses_only_group_end_tag,
|
||||
write_in_parentheses_only_group_start_tag, Parentheses,
|
||||
write_in_parentheses_only_group_start_tag,
|
||||
};
|
||||
use crate::expression::OperatorPrecedence;
|
||||
use crate::prelude::*;
|
||||
use crate::string::implicit::FormatImplicitConcatenatedString;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use ruff_formatter::{write, FormatRuleWithOptions};
|
||||
use ruff_formatter::{FormatRuleWithOptions, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::{Expr, ExprAttribute, ExprNumberLiteral, Number};
|
||||
use ruff_python_trivia::{find_only_token_in_range, SimpleTokenKind, SimpleTokenizer};
|
||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer, find_only_token_in_range};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::comments::dangling_comments;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
|
||||
};
|
||||
use crate::expression::CallChainLayout;
|
||||
use crate::expression::parentheses::{
|
||||
NeedsParentheses, OptionalParentheses, Parentheses, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_python_ast::ExprAwait;
|
|||
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parenthesize,
|
||||
NeedsParentheses, OptionalParentheses, Parenthesize, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ use ruff_python_ast::ExprBytesLiteral;
|
|||
use ruff_python_ast::{AnyNodeRef, StringLike};
|
||||
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, in_parentheses_only_group,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
use crate::string::implicit::FormatImplicitConcatenatedStringFlat;
|
||||
use crate::string::{implicit::FormatImplicitConcatenatedString, StringLikeExtensions};
|
||||
use crate::string::{StringLikeExtensions, implicit::FormatImplicitConcatenatedString};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprBytesLiteral;
|
||||
|
|
|
@ -3,10 +3,10 @@ use ruff_python_ast::AnyNodeRef;
|
|||
use ruff_python_ast::{Expr, ExprCall};
|
||||
|
||||
use crate::comments::dangling_comments;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
|
||||
};
|
||||
use crate::expression::CallChainLayout;
|
||||
use crate::expression::parentheses::{
|
||||
NeedsParentheses, OptionalParentheses, Parentheses, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -2,9 +2,9 @@ use ruff_formatter::{format_args, write};
|
|||
use ruff_python_ast::{AnyNodeRef, DictItem, Expr, ExprDict};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::comments::{dangling_comments, leading_comments, SourceComment};
|
||||
use crate::comments::{SourceComment, dangling_comments, leading_comments};
|
||||
use crate::expression::parentheses::{
|
||||
empty_parenthesized, parenthesized, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, empty_parenthesized, parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_python_ast::ExprDictComp;
|
|||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::comments::dangling_comments;
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, parenthesized};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use ruff_python_ast::{AnyNodeRef, ExprFString, StringLike};
|
||||
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, in_parentheses_only_group,
|
||||
};
|
||||
use crate::other::f_string::FStringLayout;
|
||||
use crate::prelude::*;
|
||||
use crate::string::StringLikeExtensions;
|
||||
use crate::string::implicit::{
|
||||
FormatImplicitConcatenatedString, FormatImplicitConcatenatedStringFlat,
|
||||
};
|
||||
use crate::string::StringLikeExtensions;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprFString;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_formatter::{FormatRuleWithOptions, format_args, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::ExprGenerator;
|
||||
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, parenthesized};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Default)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use ruff_formatter::{write, FormatRuleWithOptions};
|
||||
use ruff_formatter::{FormatRuleWithOptions, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::{Expr, ExprIf};
|
||||
|
||||
use crate::comments::leading_comments;
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, in_parentheses_only_soft_line_break_or_space,
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, in_parentheses_only_group,
|
||||
in_parentheses_only_soft_line_break_or_space, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_python_ast::ExprList;
|
|||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::expression::parentheses::{
|
||||
empty_parenthesized, parenthesized, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, empty_parenthesized, parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use ruff_formatter::{format_args, write, FormatResult};
|
||||
use ruff_formatter::{FormatResult, format_args, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::ExprListComp;
|
||||
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, parenthesized};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_python_ast::ExprNamed;
|
|||
|
||||
use crate::comments::dangling_comments;
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_soft_line_break_or_space, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, in_parentheses_only_soft_line_break_or_space,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::AnyNodeRef;
|
|||
use ruff_python_ast::ExprSet;
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, parenthesized};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use ruff_formatter::{format_args, write, Buffer, FormatResult};
|
||||
use ruff_formatter::{Buffer, FormatResult, format_args, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::ExprSetComp;
|
||||
|
||||
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, parenthesized};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use ruff_formatter::{write, FormatError};
|
||||
use ruff_formatter::{FormatError, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::{Expr, ExprSlice, ExprUnaryOp, UnaryOp};
|
||||
use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::comments::{dangling_comments, SourceComment};
|
||||
use crate::comments::{SourceComment, dangling_comments};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::builders::parenthesize_if_expands;
|
||||
use crate::expression::parentheses::{
|
||||
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, in_parentheses_only_group,
|
||||
};
|
||||
use crate::other::string_literal::StringLiteralKind;
|
||||
use crate::prelude::*;
|
||||
|
@ -8,7 +8,7 @@ use crate::string::implicit::{
|
|||
FormatImplicitConcatenatedStringExpanded, FormatImplicitConcatenatedStringFlat,
|
||||
ImplicitConcatenatedLayout,
|
||||
};
|
||||
use crate::string::{implicit::FormatImplicitConcatenatedString, StringLikeExtensions};
|
||||
use crate::string::{StringLikeExtensions, implicit::FormatImplicitConcatenatedString};
|
||||
use ruff_formatter::FormatRuleWithOptions;
|
||||
use ruff_python_ast::{AnyNodeRef, ExprStringLiteral, StringLike};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use ruff_formatter::{write, FormatRuleWithOptions};
|
||||
use ruff_formatter::{FormatRuleWithOptions, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::{Expr, ExprSubscript};
|
||||
|
||||
use crate::expression::CallChainLayout;
|
||||
use crate::expression::expr_tuple::TupleParentheses;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
|
||||
NeedsParentheses, OptionalParentheses, Parentheses, is_expression_parenthesized, parenthesized,
|
||||
};
|
||||
use crate::expression::CallChainLayout;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use ruff_formatter::{format_args, FormatRuleWithOptions};
|
||||
use ruff_formatter::{FormatRuleWithOptions, format_args};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::ExprTuple;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::builders::parenthesize_if_expands;
|
||||
use crate::expression::parentheses::{
|
||||
empty_parenthesized, optional_parentheses, parenthesized, NeedsParentheses, OptionalParentheses,
|
||||
NeedsParentheses, OptionalParentheses, empty_parenthesized, optional_parentheses, parenthesized,
|
||||
};
|
||||
use crate::other::commas::has_trailing_comma;
|
||||
use crate::prelude::*;
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_python_ast::UnaryOp;
|
|||
|
||||
use crate::comments::trailing_comments;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
|
||||
NeedsParentheses, OptionalParentheses, Parentheses, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use ruff_text_size::{Ranged, TextRange};
|
|||
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parenthesize,
|
||||
NeedsParentheses, OptionalParentheses, Parenthesize, is_expression_parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -2,21 +2,21 @@ use std::cmp::Ordering;
|
|||
use std::slice;
|
||||
|
||||
use ruff_formatter::{
|
||||
write, FormatOwnedWithRule, FormatRefWithRule, FormatRule, FormatRuleWithOptions,
|
||||
FormatOwnedWithRule, FormatRefWithRule, FormatRule, FormatRuleWithOptions, write,
|
||||
};
|
||||
use ruff_python_ast::parenthesize::parentheses_iterator;
|
||||
use ruff_python_ast::visitor::source_order::{walk_expr, SourceOrderVisitor};
|
||||
use ruff_python_ast::visitor::source_order::{SourceOrderVisitor, walk_expr};
|
||||
use ruff_python_ast::{self as ast};
|
||||
use ruff_python_ast::{AnyNodeRef, Expr, ExprRef, Operator};
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::builders::parenthesize_if_expands;
|
||||
use crate::comments::{leading_comments, trailing_comments, LeadingDanglingTrailingComments};
|
||||
use crate::comments::{LeadingDanglingTrailingComments, leading_comments, trailing_comments};
|
||||
use crate::context::{NodeLevel, WithNodeLevel};
|
||||
use crate::expression::parentheses::{
|
||||
is_expression_parenthesized, optional_parentheses, parenthesized, NeedsParentheses,
|
||||
OptionalParentheses, Parentheses, Parenthesize,
|
||||
NeedsParentheses, OptionalParentheses, Parentheses, Parenthesize, is_expression_parenthesized,
|
||||
optional_parentheses, parenthesized,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
use crate::preview::is_hug_parens_with_braces_and_square_brackets_enabled;
|
||||
|
@ -391,7 +391,7 @@ impl Format<PyFormatContext<'_>> for MaybeParenthesizeExpression<'_> {
|
|||
.fmt(f)
|
||||
} else {
|
||||
expression.format().with_options(Parentheses::Never).fmt(f)
|
||||
}
|
||||
};
|
||||
}
|
||||
needs_parentheses => needs_parentheses,
|
||||
};
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use ruff_formatter::prelude::tag::Condition;
|
||||
use ruff_formatter::{format_args, write, Argument, Arguments};
|
||||
use ruff_formatter::{Argument, Arguments, format_args, write};
|
||||
use ruff_python_ast::AnyNodeRef;
|
||||
use ruff_python_ast::ExprRef;
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
use ruff_python_trivia::{
|
||||
first_non_trivia_token, BackwardsTokenizer, SimpleToken, SimpleTokenKind,
|
||||
BackwardsTokenizer, SimpleToken, SimpleTokenKind, first_non_trivia_token,
|
||||
};
|
||||
use ruff_text_size::Ranged;
|
||||
|
||||
use crate::comments::{
|
||||
dangling_comments, dangling_open_parenthesis_comments, trailing_comments, SourceComment,
|
||||
SourceComment, dangling_comments, dangling_open_parenthesis_comments, trailing_comments,
|
||||
};
|
||||
use crate::context::{NodeLevel, WithNodeLevel};
|
||||
use crate::prelude::*;
|
||||
|
@ -422,9 +422,11 @@ impl Format<PyFormatContext<'_>> for FormatEmptyParenthesized<'_> {
|
|||
let end_of_line_split = self
|
||||
.comments
|
||||
.partition_point(|comment| comment.line_position().is_end_of_line());
|
||||
debug_assert!(self.comments[end_of_line_split..]
|
||||
.iter()
|
||||
.all(|comment| comment.line_position().is_own_line()));
|
||||
debug_assert!(
|
||||
self.comments[end_of_line_split..]
|
||||
.iter()
|
||||
.all(|comment| comment.line_position().is_own_line())
|
||||
);
|
||||
group(&format_args![
|
||||
token(self.left),
|
||||
// end-of-line comments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue