mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +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,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue