mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Pull in RustPython parser (#6099)
This commit is contained in:
parent
86539c1fc5
commit
40f54375cb
779 changed files with 108400 additions and 2078 deletions
|
@ -16,7 +16,8 @@ ruff_python_trivia = { path = "../ruff_python_trivia" }
|
|||
ruff_source_file = { path = "../ruff_source_file" }
|
||||
ruff_python_ast = { path = "../ruff_python_ast" }
|
||||
ruff_python_index = { path = "../ruff_python_index" }
|
||||
ruff_text_size = { workspace = true }
|
||||
ruff_python_parser = { path = "../ruff_python_parser" }
|
||||
ruff_text_size = { path = "../ruff_text_size" }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
bitflags = { workspace = true }
|
||||
|
@ -26,8 +27,6 @@ is-macro = { workspace = true }
|
|||
itertools = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
rustpython-ast = { workspace = true }
|
||||
rustpython-parser = { workspace = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
smallvec = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
|
|
@ -90,7 +90,7 @@ for group, group_nodes in nodes_grouped.items():
|
|||
code = f"""
|
||||
use crate::{{verbatim_text, FormatNodeRule, PyFormatter}};
|
||||
use ruff_formatter::{{write, Buffer, FormatResult}};
|
||||
use rustpython_ast::{node};
|
||||
use ruff_python_ast::{node};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Format{node};
|
||||
|
@ -114,7 +114,7 @@ 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;
|
||||
use ruff_python_ast as ast;
|
||||
|
||||
""" # noqa: E501
|
||||
for node in nodes:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::Ranged;
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::Ranged;
|
||||
|
||||
use crate::comments::{dangling_comments, SourceComment};
|
||||
use ruff_formatter::{format_args, write, Argument, Arguments};
|
||||
|
@ -377,8 +377,8 @@ impl<'ast> Format<PyFormatContext<'ast>> for EmptyWithDanglingComments<'_> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rustpython_ast::ModModule;
|
||||
use rustpython_parser::Parse;
|
||||
use ruff_python_ast::ModModule;
|
||||
use ruff_python_parser::Parse;
|
||||
|
||||
use ruff_formatter::format;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::path::PathBuf;
|
|||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use clap::{command, Parser, ValueEnum};
|
||||
use rustpython_parser::lexer::lex;
|
||||
use rustpython_parser::{parse_tokens, Mode};
|
||||
use ruff_python_parser::lexer::lex;
|
||||
use ruff_python_parser::{parse_tokens, Mode};
|
||||
|
||||
use ruff_formatter::SourceCode;
|
||||
use ruff_python_index::CommentRangesBuilder;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::fmt::{Debug, Formatter, Write};
|
||||
|
||||
use itertools::Itertools;
|
||||
use rustpython_ast::Ranged;
|
||||
use ruff_python_ast::Ranged;
|
||||
|
||||
use ruff_formatter::SourceCode;
|
||||
|
||||
|
@ -178,8 +178,8 @@ impl Debug for DebugNodeCommentSlice<'_> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use insta::assert_debug_snapshot;
|
||||
use ruff_python_ast::{StmtBreak, StmtContinue};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::{StmtBreak, StmtContinue};
|
||||
|
||||
use ruff_formatter::SourceCode;
|
||||
use ruff_python_ast::node::AnyNode;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::Ranged;
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
use rustpython_ast::Ranged;
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatError, SourceCode};
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
|
|
|
@ -92,7 +92,7 @@ use std::cell::Cell;
|
|||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustpython_ast::{Mod, Ranged};
|
||||
use ruff_python_ast::{Mod, Ranged};
|
||||
|
||||
pub(crate) use format::{
|
||||
dangling_comments, dangling_node_comments, leading_alternate_branch_comments, leading_comments,
|
||||
|
@ -414,9 +414,9 @@ struct CommentsData<'a> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use insta::assert_debug_snapshot;
|
||||
use rustpython_ast::Mod;
|
||||
use rustpython_parser::lexer::lex;
|
||||
use rustpython_parser::{parse_tokens, Mode};
|
||||
use ruff_python_ast::Mod;
|
||||
use ruff_python_parser::lexer::lex;
|
||||
use ruff_python_parser::{parse_tokens, Mode};
|
||||
|
||||
use ruff_formatter::SourceCode;
|
||||
use ruff_python_index::{CommentRanges, CommentRangesBuilder};
|
||||
|
|
|
@ -53,8 +53,8 @@ impl<'a> From<AnyNodeRef<'a>> for NodeRefEqualityKey<'a> {
|
|||
mod tests {
|
||||
use crate::comments::node_key::NodeRefEqualityKey;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::StmtContinue;
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::StmtContinue;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use std::cmp::Ordering;
|
||||
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_parser::ast;
|
||||
use rustpython_parser::ast::{
|
||||
Arguments, Comprehension, Expr, ExprAttribute, ExprBinOp, ExprIfExp, ExprSlice, ExprStarred,
|
||||
MatchCase, Ranged,
|
||||
use ruff_python_ast::{
|
||||
self as ast, Arguments, Comprehension, Expr, ExprAttribute, ExprBinOp, ExprIfExp, ExprSlice,
|
||||
ExprStarred, MatchCase, Ranged,
|
||||
};
|
||||
use ruff_text_size::TextRange;
|
||||
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
use ruff_python_ast::whitespace::indentation;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::iter::Peekable;
|
||||
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::{
|
||||
use ruff_python_ast::{
|
||||
Alias, Arg, ArgWithDefault, Arguments, Comprehension, Decorator, ElifElseClause, ExceptHandler,
|
||||
Expr, Keyword, MatchCase, Mod, Pattern, Ranged, Stmt, TypeParam, WithItem,
|
||||
};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
|
||||
use ruff_formatter::{SourceCode, SourceCodeSlice};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{Constant, Expr, ExprAttribute, ExprConstant};
|
||||
use ruff_python_ast::{Constant, Expr, ExprAttribute, ExprConstant};
|
||||
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::ExprAwait;
|
||||
use ruff_python_ast::ExprAwait;
|
||||
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::iter;
|
||||
|
||||
use rustpython_ast::{
|
||||
use ruff_python_ast::{
|
||||
Constant, Expr, ExprAttribute, ExprBinOp, ExprConstant, ExprUnaryOp, Operator, UnaryOp,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::expression::parentheses::{
|
|||
use crate::prelude::*;
|
||||
use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::{BoolOp, ExprBoolOp};
|
||||
use ruff_python_ast::{BoolOp, ExprBoolOp};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprBoolOp {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::{Expr, ExprCall, Ranged};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::{Expr, ExprCall, Ranged};
|
||||
|
||||
use crate::builders::empty_parenthesized_with_dangling_comments;
|
||||
use ruff_formatter::write;
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::{CmpOp, ExprCompare};
|
||||
use ruff_python_ast::{CmpOp, ExprCompare};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprCompare {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::{Constant, ExprConstant, Ranged};
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
use rustpython_ast::{Constant, ExprConstant, Ranged};
|
||||
|
||||
use ruff_formatter::FormatRuleWithOptions;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -5,9 +5,9 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::{format_args, write};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::Ranged;
|
||||
use ruff_python_ast::{Expr, ExprDict};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::Ranged;
|
||||
use rustpython_ast::{Expr, ExprDict};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprDict;
|
||||
|
|
|
@ -7,7 +7,7 @@ use ruff_formatter::prelude::{
|
|||
};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprDictComp;
|
||||
use ruff_python_ast::ExprDictComp;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprDictComp;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprFormattedValue;
|
||||
use ruff_python_ast::ExprFormattedValue;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprFormattedValue;
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::AsFormat;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{format_args, write, Buffer, FormatResult, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprGeneratorExp;
|
||||
use ruff_python_ast::ExprGeneratorExp;
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Default)]
|
||||
pub enum GeneratorExpParentheses {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::{format_args, write};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprIfExp;
|
||||
use ruff_python_ast::ExprIfExp;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprIfExp;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
|||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprJoinedStr;
|
||||
use ruff_python_ast::ExprJoinedStr;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprJoinedStr;
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{FormatNodeRule, PyFormatter};
|
|||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprLambda;
|
||||
use ruff_python_ast::ExprLambda;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprLambda;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalPa
|
|||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::{ExprList, Ranged};
|
||||
use ruff_python_ast::{ExprList, Ranged};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprList;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::AsFormat;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{format_args, write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprListComp;
|
||||
use ruff_python_ast::ExprListComp;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprListComp;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::{write, FormatContext};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprName;
|
||||
use ruff_python_ast::ExprName;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprName;
|
||||
|
@ -36,9 +36,9 @@ impl NeedsParentheses for ExprName {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ruff_python_ast::{ModModule, Ranged};
|
||||
use ruff_python_parser::Parse;
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::{ModModule, Ranged};
|
||||
use rustpython_parser::Parse;
|
||||
|
||||
#[test]
|
||||
fn name_range_with_comments() {
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
|||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprNamedExpr;
|
||||
use ruff_python_ast::ExprNamedExpr;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprNamedExpr;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{ExprSet, Ranged};
|
||||
use ruff_python_ast::{ExprSet, Ranged};
|
||||
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::AsFormat;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{format_args, write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprSetComp;
|
||||
use ruff_python_ast::ExprSetComp;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprSetComp;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::{Expr, ExprSlice, ExprUnaryOp, Ranged, UnaryOp};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::{Expr, ExprSlice, ExprUnaryOp, Ranged, UnaryOp};
|
||||
|
||||
use ruff_formatter::prelude::{hard_line_break, line_suffix_boundary, space, text};
|
||||
use ruff_formatter::{write, Buffer, Format, FormatError, FormatResult};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::ExprStarred;
|
||||
use ruff_python_ast::ExprStarred;
|
||||
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{Expr, ExprSubscript};
|
||||
use ruff_python_ast::{Expr, ExprSubscript};
|
||||
|
||||
use ruff_formatter::{format_args, write};
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruff_python_ast::ExprTuple;
|
||||
use ruff_python_ast::{Expr, Ranged};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::ExprTuple;
|
||||
use rustpython_ast::{Expr, Ranged};
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruff_python_ast::UnaryOp;
|
||||
use ruff_python_ast::{ExprUnaryOp, Ranged};
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
use rustpython_ast::UnaryOp;
|
||||
use rustpython_ast::{ExprUnaryOp, Ranged};
|
||||
|
||||
use ruff_formatter::prelude::{hard_line_break, space, text};
|
||||
use ruff_formatter::{Format, FormatContext, FormatResult};
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{FormatNodeRule, PyFormatter};
|
|||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprYield;
|
||||
use ruff_python_ast::ExprYield;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprYield;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{FormatNodeRule, PyFormatter};
|
|||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::ExprYieldFrom;
|
||||
use ruff_python_ast::ExprYieldFrom;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatExprYieldFrom;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cmp::Ordering;
|
||||
|
||||
use rustpython_ast::{Expr, Operator};
|
||||
use rustpython_parser::ast;
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::{Expr, Operator};
|
||||
|
||||
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatRule, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
@ -383,7 +383,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
|
|||
}
|
||||
}
|
||||
|
||||
// `[a, b].test[300].dot`
|
||||
// `[a, b].test.test[300].dot`
|
||||
Expr::Attribute(ast::ExprAttribute {
|
||||
range: _,
|
||||
value,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use ruff_python_ast::{ExprConstant, Ranged};
|
||||
use ruff_text_size::TextSize;
|
||||
use rustpython_ast::{ExprConstant, Ranged};
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::Ranged;
|
||||
use ruff_python_ast::Ranged;
|
||||
|
||||
use ruff_formatter::prelude::tag::Condition;
|
||||
use ruff_formatter::{format_args, write, Argument, Arguments};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use ruff_python_ast::{ExprConstant, Ranged};
|
||||
use ruff_python_parser::lexer::{lex_starts_at, LexicalError, LexicalErrorType};
|
||||
use ruff_python_parser::{Mode, Tok};
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
use rustpython_ast::{ExprConstant, Ranged};
|
||||
use rustpython_parser::lexer::{lex_starts_at, LexicalError, LexicalErrorType};
|
||||
use rustpython_parser::{Mode, Tok};
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatError};
|
||||
use ruff_python_ast::str::is_implicit_concatenation;
|
||||
|
|
|
@ -5,7 +5,7 @@ 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;
|
||||
use ruff_python_ast as ast;
|
||||
|
||||
impl FormatRule<ast::ModModule, PyFormatContext<'_>>
|
||||
for crate::module::mod_module::FormatModModule
|
||||
|
|
|
@ -13,12 +13,12 @@ use ruff_formatter::{
|
|||
};
|
||||
use ruff_formatter::{Formatted, Printed, SourceCode};
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode, NodeKind};
|
||||
use ruff_python_ast::{Mod, Ranged};
|
||||
use ruff_python_index::{CommentRanges, CommentRangesBuilder};
|
||||
use ruff_python_parser::lexer::{lex, LexicalError};
|
||||
use ruff_python_parser::{parse_tokens, Mode, ParseError};
|
||||
use ruff_source_file::Locator;
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
use rustpython_ast::{Mod, Ranged};
|
||||
use rustpython_parser::lexer::{lex, LexicalError};
|
||||
use rustpython_parser::{parse_tokens, Mode, ParseError};
|
||||
use std::borrow::Cow;
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -251,8 +251,8 @@ mod tests {
|
|||
use anyhow::Result;
|
||||
use insta::assert_snapshot;
|
||||
use ruff_python_index::CommentRangesBuilder;
|
||||
use rustpython_parser::lexer::lex;
|
||||
use rustpython_parser::{parse_tokens, Mode};
|
||||
use ruff_python_parser::lexer::lex;
|
||||
use ruff_python_parser::{parse_tokens, Mode};
|
||||
|
||||
/// Very basic test intentionally kept very similar to the CLI
|
||||
#[test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::context::PyFormatContext;
|
||||
use crate::{AsFormat, IntoFormat, PyFormatter};
|
||||
use ruff_formatter::{Format, FormatOwnedWithRule, FormatRefWithRule, FormatResult, FormatRule};
|
||||
use rustpython_ast::Mod;
|
||||
use ruff_python_ast::Mod;
|
||||
|
||||
pub(crate) mod mod_expression;
|
||||
pub(crate) mod mod_function_type;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{Format, FormatResult};
|
||||
use rustpython_ast::ModExpression;
|
||||
use ruff_python_ast::ModExpression;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatModExpression;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::ModFunctionType;
|
||||
use ruff_python_ast::ModFunctionType;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatModFunctionType;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::ModInteractive;
|
||||
use ruff_python_ast::ModInteractive;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatModInteractive;
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::statement::suite::SuiteLevel;
|
|||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::hard_line_break;
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::ModModule;
|
||||
use ruff_python_ast::ModModule;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatModModule;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, Format, FormatResult};
|
||||
use rustpython_ast::Alias;
|
||||
use ruff_python_ast::Alias;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatAlias;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use rustpython_ast::Arg;
|
||||
use ruff_python_ast::Arg;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatArg;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_formatter::write;
|
||||
use rustpython_ast::ArgWithDefault;
|
||||
use ruff_python_ast::ArgWithDefault;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::usize;
|
||||
|
||||
use ruff_python_ast::{Arguments, Ranged};
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use rustpython_ast::{Arguments, Ranged};
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_python_ast::node::{AnyNodeRef, AstNode};
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::prelude::*;
|
|||
use crate::AsFormat;
|
||||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{format_args, write, Buffer, FormatResult};
|
||||
use rustpython_ast::{Comprehension, Expr, Ranged};
|
||||
use ruff_python_ast::{Comprehension, Expr, Ranged};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatComprehension;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use rustpython_ast::Decorator;
|
||||
use ruff_python_ast::Decorator;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatDecorator;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::statement::stmt_if::format_elif_else_clause;
|
||||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_ast::ElifElseClause;
|
||||
use ruff_python_ast::ElifElseClause;
|
||||
|
||||
/// 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
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatRuleWithOptions;
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::ExceptHandlerExceptHandler;
|
||||
use ruff_python_ast::ExceptHandlerExceptHandler;
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub enum ExceptHandlerKind {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::AsFormat;
|
||||
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule};
|
||||
use rustpython_ast::{Identifier, Ranged};
|
||||
use ruff_python_ast::{Identifier, Ranged};
|
||||
|
||||
pub struct FormatIdentifier;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use rustpython_ast::Keyword;
|
||||
use ruff_python_ast::Keyword;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatKeyword;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::MatchCase;
|
||||
use ruff_python_ast::MatchCase;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatMatchCase;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::TypeIgnoreTypeIgnore;
|
||||
use ruff_python_ast::TypeIgnoreTypeIgnore;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatTypeIgnoreTypeIgnore;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::WithItem;
|
||||
use ruff_python_ast::WithItem;
|
||||
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchAs;
|
||||
use ruff_python_ast::PatternMatchAs;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchAs;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchClass;
|
||||
use ruff_python_ast::PatternMatchClass;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchClass;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchMapping;
|
||||
use ruff_python_ast::PatternMatchMapping;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchMapping;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchOr;
|
||||
use ruff_python_ast::PatternMatchOr;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchOr;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchSequence;
|
||||
use ruff_python_ast::PatternMatchSequence;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchSequence;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchSingleton;
|
||||
use ruff_python_ast::PatternMatchSingleton;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchSingleton;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::PatternMatchStar;
|
||||
use ruff_python_ast::PatternMatchStar;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatPatternMatchStar;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::PatternMatchValue;
|
||||
use ruff_python_ast::PatternMatchValue;
|
||||
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule};
|
||||
use rustpython_ast::Stmt;
|
||||
use ruff_python_ast::Stmt;
|
||||
|
||||
pub(crate) mod stmt_ann_assign;
|
||||
pub(crate) mod stmt_assert;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use rustpython_ast::StmtAnnAssign;
|
||||
use ruff_python_ast::StmtAnnAssign;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAnnAssign;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtAssert;
|
||||
use ruff_python_ast::StmtAssert;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAssert;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{Expr, StmtAssign};
|
||||
use ruff_python_ast::{Expr, StmtAssign};
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatError};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::prelude::*;
|
|||
use crate::statement::stmt_for::AnyStatementFor;
|
||||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_ast::StmtAsyncFor;
|
||||
use ruff_python_ast::StmtAsyncFor;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAsyncFor;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::StmtAsyncFunctionDef;
|
||||
use ruff_python_ast::StmtAsyncFunctionDef;
|
||||
|
||||
use ruff_python_ast::function::AnyFunctionDefinition;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::statement::stmt_with::AnyStatementWith;
|
||||
use crate::FormatNodeRule;
|
||||
use rustpython_ast::StmtAsyncWith;
|
||||
use ruff_python_ast::StmtAsyncWith;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAsyncWith;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtAugAssign;
|
||||
use ruff_python_ast::StmtAugAssign;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtAugAssign;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::text;
|
||||
use ruff_formatter::{Format, FormatResult};
|
||||
use rustpython_ast::StmtBreak;
|
||||
use ruff_python_ast::StmtBreak;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtBreak;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::{Ranged, StmtClassDef};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::{Ranged, StmtClassDef};
|
||||
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::text;
|
||||
use ruff_formatter::{Format, FormatResult};
|
||||
use rustpython_ast::StmtContinue;
|
||||
use ruff_python_ast::StmtContinue;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtContinue;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{block_indent, format_with, space, text};
|
||||
use ruff_formatter::{write, Buffer, Format, FormatResult};
|
||||
use rustpython_ast::{Ranged, StmtDelete};
|
||||
use ruff_python_ast::{Ranged, StmtDelete};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtDelete;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use rustpython_ast::{Expr, Operator, StmtExpr};
|
||||
use rustpython_parser::ast;
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::{Expr, Operator, StmtExpr};
|
||||
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::Parenthesize;
|
||||
|
|
|
@ -6,8 +6,8 @@ use crate::prelude::*;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{format_args, write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::{Expr, Ranged, Stmt, StmtAsyncFor, StmtFor, Suite};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::{Expr, Ranged, Stmt, StmtAsyncFor, StmtFor, Suite};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ExprTupleWithoutParentheses<'a>(&'a Expr);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{Ranged, StmtFunctionDef};
|
||||
use ruff_python_ast::{Ranged, StmtFunctionDef};
|
||||
|
||||
use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule};
|
||||
use ruff_python_ast::function::AnyFunctionDefinition;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtGlobal;
|
||||
use ruff_python_ast::StmtGlobal;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtGlobal;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_ast::{ElifElseClause, StmtIf};
|
||||
use ruff_python_ast::{ElifElseClause, StmtIf};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtIf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{FormatNodeRule, FormattedIterExt, PyFormatter};
|
||||
use ruff_formatter::prelude::{format_args, format_with, space, text};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtImport;
|
||||
use ruff_python_ast::StmtImport;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtImport;
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::builders::{parenthesize_if_expands, PyFormatterExtensions};
|
|||
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{dynamic_text, format_with, space, text};
|
||||
use ruff_formatter::{write, Buffer, Format, FormatResult};
|
||||
use rustpython_ast::{Ranged, StmtImportFrom};
|
||||
use ruff_python_ast::{Ranged, StmtImportFrom};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtImportFrom;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtMatch;
|
||||
use ruff_python_ast::StmtMatch;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtMatch;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtNonlocal;
|
||||
use ruff_python_ast::StmtNonlocal;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtNonlocal;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::text;
|
||||
use ruff_formatter::{Format, FormatResult};
|
||||
use rustpython_ast::StmtPass;
|
||||
use ruff_python_ast::StmtPass;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtPass;
|
||||
|
|
|
@ -4,7 +4,7 @@ use ruff_formatter::prelude::{space, text};
|
|||
use ruff_formatter::{write, Buffer, Format, FormatResult};
|
||||
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use rustpython_ast::StmtRaise;
|
||||
use ruff_python_ast::StmtRaise;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtRaise;
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::expression::parentheses::Parenthesize;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::prelude::{space, text};
|
||||
use ruff_formatter::{write, Buffer, Format, FormatResult};
|
||||
use rustpython_ast::StmtReturn;
|
||||
use ruff_python_ast::StmtReturn;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtReturn;
|
||||
|
|
|
@ -9,8 +9,8 @@ use crate::{FormatNodeRule, PyFormatter};
|
|||
use ruff_formatter::FormatRuleWithOptions;
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::{ExceptHandler, Ranged, StmtTry, StmtTryStar, Suite};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::{ExceptHandler, Ranged, StmtTry, StmtTryStar, Suite};
|
||||
|
||||
pub(super) enum AnyStatementTry<'a> {
|
||||
Try(&'a StmtTry),
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::statement::stmt_try::AnyStatementTry;
|
|||
use crate::{FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::Format;
|
||||
use ruff_formatter::FormatResult;
|
||||
use rustpython_ast::StmtTryStar;
|
||||
use ruff_python_ast::StmtTryStar;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtTryStar;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use rustpython_ast::StmtTypeAlias;
|
||||
use ruff_python_ast::StmtTypeAlias;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtTypeAlias;
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
|||
use crate::FormatNodeRule;
|
||||
use ruff_formatter::write;
|
||||
use ruff_python_ast::node::AstNode;
|
||||
use rustpython_ast::{Ranged, Stmt, StmtWhile};
|
||||
use ruff_python_ast::{Ranged, Stmt, StmtWhile};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FormatStmtWhile;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruff_python_ast::{Ranged, StmtAsyncWith, StmtWith, Suite, WithItem};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustpython_ast::{Ranged, StmtAsyncWith, StmtWith, Suite, WithItem};
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatError};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustpython_ast::{Ranged, Stmt, Suite};
|
||||
use ruff_python_ast::{Ranged, Stmt, Suite};
|
||||
|
||||
use ruff_formatter::{
|
||||
format_args, write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions,
|
||||
|
@ -170,8 +170,8 @@ impl<'ast> IntoFormat<PyFormatContext<'ast>> for Suite {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rustpython_ast::Suite;
|
||||
use rustpython_parser::Parse;
|
||||
use ruff_python_ast::Suite;
|
||||
use ruff_python_parser::Parse;
|
||||
|
||||
use ruff_formatter::format;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue