Pull in RustPython parser (#6099)

This commit is contained in:
Micha Reiser 2023-07-27 11:29:11 +02:00 committed by GitHub
parent 86539c1fc5
commit 40f54375cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
779 changed files with 108400 additions and 2078 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,4 +1,4 @@
use rustpython_ast::{Expr, StmtAssign};
use ruff_python_ast::{Expr, StmtAssign};
use ruff_formatter::{format_args, write, FormatError};

View file

@ -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;

View file

@ -1,4 +1,4 @@
use rustpython_ast::StmtAsyncFunctionDef;
use ruff_python_ast::StmtAsyncFunctionDef;
use ruff_python_ast::function::AnyFunctionDefinition;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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),

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;