mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:09 +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
|
@ -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