Remove parser dependency from ruff-python-ast (#6096)

This commit is contained in:
Micha Reiser 2023-07-26 17:47:22 +02:00 committed by GitHub
parent 99127243f4
commit 2cf00fee96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
658 changed files with 1714 additions and 1546 deletions

99
Cargo.lock generated
View file

@ -1905,13 +1905,16 @@ dependencies = [
"ruff_index", "ruff_index",
"ruff_macros", "ruff_macros",
"ruff_python_ast", "ruff_python_ast",
"ruff_python_codegen",
"ruff_python_index",
"ruff_python_parser",
"ruff_python_semantic", "ruff_python_semantic",
"ruff_python_stdlib", "ruff_python_stdlib",
"ruff_python_trivia", "ruff_python_trivia",
"ruff_rustpython", "ruff_source_file",
"ruff_text_size", "ruff_text_size",
"ruff_textwrap",
"rustc-hash", "rustc-hash",
"rustpython-ast",
"rustpython-format", "rustpython-format",
"rustpython-parser", "rustpython-parser",
"schemars", "schemars",
@ -1944,6 +1947,7 @@ dependencies = [
"ruff", "ruff",
"ruff_python_ast", "ruff_python_ast",
"ruff_python_formatter", "ruff_python_formatter",
"rustpython-ast",
"rustpython-parser", "rustpython-parser",
"serde", "serde",
"serde_json", "serde_json",
@ -1999,8 +2003,9 @@ dependencies = [
"ruff_python_ast", "ruff_python_ast",
"ruff_python_formatter", "ruff_python_formatter",
"ruff_python_stdlib", "ruff_python_stdlib",
"ruff_python_trivia",
"ruff_source_file",
"ruff_text_size", "ruff_text_size",
"ruff_textwrap",
"rustc-hash", "rustc-hash",
"serde", "serde",
"serde_json", "serde_json",
@ -2034,9 +2039,11 @@ dependencies = [
"ruff_cli", "ruff_cli",
"ruff_diagnostics", "ruff_diagnostics",
"ruff_formatter", "ruff_formatter",
"ruff_python_codegen",
"ruff_python_formatter", "ruff_python_formatter",
"ruff_python_stdlib", "ruff_python_stdlib",
"ruff_textwrap", "ruff_python_trivia",
"rustpython-ast",
"rustpython-format", "rustpython-format",
"rustpython-parser", "rustpython-parser",
"schemars", "schemars",
@ -2089,7 +2096,7 @@ dependencies = [
"itertools", "itertools",
"proc-macro2", "proc-macro2",
"quote", "quote",
"ruff_textwrap", "ruff_python_trivia",
"syn 2.0.23", "syn 2.0.23",
] ]
@ -2097,25 +2104,35 @@ dependencies = [
name = "ruff_python_ast" name = "ruff_python_ast"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"anyhow",
"bitflags 2.3.3", "bitflags 2.3.3",
"insta", "insta",
"is-macro", "is-macro",
"itertools",
"memchr", "memchr",
"num-bigint", "num-bigint",
"num-traits", "num-traits",
"once_cell", "once_cell",
"ruff_python_trivia", "ruff_python_trivia",
"ruff_source_file",
"ruff_text_size", "ruff_text_size",
"rustc-hash", "rustc-hash",
"rustpython-ast", "rustpython-ast",
"rustpython-literal",
"rustpython-parser", "rustpython-parser",
"serde", "serde",
"smallvec", "smallvec",
] ]
[[package]]
name = "ruff_python_codegen"
version = "0.0.0"
dependencies = [
"once_cell",
"ruff_python_ast",
"ruff_source_file",
"rustpython-ast",
"rustpython-literal",
"rustpython-parser",
]
[[package]] [[package]]
name = "ruff_python_formatter" name = "ruff_python_formatter"
version = "0.0.0" version = "0.0.0"
@ -2130,9 +2147,12 @@ dependencies = [
"once_cell", "once_cell",
"ruff_formatter", "ruff_formatter",
"ruff_python_ast", "ruff_python_ast",
"ruff_python_index",
"ruff_python_trivia", "ruff_python_trivia",
"ruff_source_file",
"ruff_text_size", "ruff_text_size",
"rustc-hash", "rustc-hash",
"rustpython-ast",
"rustpython-parser", "rustpython-parser",
"serde", "serde",
"serde_json", "serde_json",
@ -2141,6 +2161,30 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "ruff_python_index"
version = "0.0.0"
dependencies = [
"itertools",
"ruff_python_trivia",
"ruff_source_file",
"ruff_text_size",
"rustpython-ast",
"rustpython-parser",
]
[[package]]
name = "ruff_python_parser"
version = "0.0.0"
dependencies = [
"anyhow",
"is-macro",
"ruff_python_ast",
"ruff_text_size",
"rustpython-ast",
"rustpython-parser",
]
[[package]] [[package]]
name = "ruff_python_resolver" name = "ruff_python_resolver"
version = "0.0.0" version = "0.0.0"
@ -2161,8 +2205,10 @@ dependencies = [
"ruff_index", "ruff_index",
"ruff_python_ast", "ruff_python_ast",
"ruff_python_stdlib", "ruff_python_stdlib",
"ruff_source_file",
"ruff_text_size", "ruff_text_size",
"rustc-hash", "rustc-hash",
"rustpython-ast",
"rustpython-parser", "rustpython-parser",
"smallvec", "smallvec",
] ]
@ -2177,19 +2223,14 @@ version = "0.0.0"
dependencies = [ dependencies = [
"insta", "insta",
"memchr", "memchr",
"ruff_source_file",
"ruff_text_size", "ruff_text_size",
"rustpython-ast",
"rustpython-parser",
"smallvec", "smallvec",
"unic-ucd-ident", "unic-ucd-ident",
] ]
[[package]]
name = "ruff_rustpython"
version = "0.0.0"
dependencies = [
"anyhow",
"rustpython-parser",
]
[[package]] [[package]]
name = "ruff_shrinking" name = "ruff_shrinking"
version = "0.1.0" version = "0.1.0"
@ -2199,13 +2240,24 @@ dependencies = [
"fs-err", "fs-err",
"regex", "regex",
"ruff_python_ast", "ruff_python_ast",
"ruff_rustpython", "ruff_python_parser",
"rustpython-ast", "rustpython-ast",
"shlex", "shlex",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
] ]
[[package]]
name = "ruff_source_file"
version = "0.0.0"
dependencies = [
"insta",
"memchr",
"once_cell",
"ruff_text_size",
"serde",
]
[[package]] [[package]]
name = "ruff_text_size" name = "ruff_text_size"
version = "0.0.0" version = "0.0.0"
@ -2215,14 +2267,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "ruff_textwrap"
version = "0.0.0"
dependencies = [
"ruff_python_trivia",
"ruff_text_size",
]
[[package]] [[package]]
name = "ruff_wasm" name = "ruff_wasm"
version = "0.0.0" version = "0.0.0"
@ -2234,8 +2278,11 @@ dependencies = [
"ruff", "ruff",
"ruff_diagnostics", "ruff_diagnostics",
"ruff_python_ast", "ruff_python_ast",
"ruff_python_codegen",
"ruff_python_formatter", "ruff_python_formatter",
"ruff_rustpython", "ruff_python_index",
"ruff_python_parser",
"ruff_source_file",
"rustpython-parser", "rustpython-parser",
"serde", "serde",
"serde-wasm-bindgen", "serde-wasm-bindgen",

View file

@ -19,13 +19,15 @@ ruff_cache = { path = "../ruff_cache" }
ruff_diagnostics = { path = "../ruff_diagnostics", features = ["serde"] } ruff_diagnostics = { path = "../ruff_diagnostics", features = ["serde"] }
ruff_index = { path = "../ruff_index" } ruff_index = { path = "../ruff_index" }
ruff_macros = { path = "../ruff_macros" } ruff_macros = { path = "../ruff_macros" }
ruff_python_trivia = { path = "../ruff_python_trivia" }
ruff_python_ast = { path = "../ruff_python_ast", features = ["serde"] } ruff_python_ast = { path = "../ruff_python_ast", features = ["serde"] }
ruff_python_codegen = { path = "../ruff_python_codegen" }
ruff_python_index = { path = "../ruff_python_index" }
ruff_python_semantic = { path = "../ruff_python_semantic" } ruff_python_semantic = { path = "../ruff_python_semantic" }
ruff_python_stdlib = { path = "../ruff_python_stdlib" } ruff_python_stdlib = { path = "../ruff_python_stdlib" }
ruff_rustpython = { path = "../ruff_rustpython" } ruff_python_trivia = { path = "../ruff_python_trivia" }
ruff_python_parser = { path = "../ruff_python_parser" }
ruff_source_file = { path = "../ruff_source_file" }
ruff_text_size = { workspace = true } ruff_text_size = { workspace = true }
ruff_textwrap = { path = "../ruff_textwrap" }
annotate-snippets = { version = "0.9.1", features = ["color"] } annotate-snippets = { version = "0.9.1", features = ["color"] }
anyhow = { workspace = true } anyhow = { workspace = true }
@ -61,6 +63,7 @@ result-like = { version = "0.4.6" }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
rustpython-format = { workspace = true } rustpython-format = { workspace = true }
rustpython-parser = { workspace = true } rustpython-parser = { workspace = true }
rustpython-ast = { workspace = true }
schemars = { workspace = true, optional = true } schemars = { workspace = true, optional = true }
semver = { version = "1.0.16" } semver = { version = "1.0.16" }
serde = { workspace = true } serde = { workspace = true }

View file

@ -4,9 +4,10 @@ use anyhow::{bail, Result};
use libcst_native::{ use libcst_native::{
Codegen, CodegenState, ImportNames, ParenthesizableWhitespace, SmallStatement, Statement, Codegen, CodegenState, ImportNames, ParenthesizableWhitespace, SmallStatement, Statement,
}; };
use rustpython_parser::ast::{Ranged, Stmt}; use rustpython_ast::{Ranged, Stmt};
use ruff_python_ast::source_code::{Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_source_file::Locator;
use crate::cst::helpers::compose_module_path; use crate::cst::helpers::compose_module_path;
use crate::cst::matchers::match_statement; use crate::cst::matchers::match_statement;

View file

@ -1,13 +1,14 @@
//! Interface for generating autofix edits from higher-level actions (e.g., "remove an argument"). //! Interface for generating autofix edits from higher-level actions (e.g., "remove an argument").
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use ruff_text_size::{TextLen, TextRange, TextSize}; use ruff_text_size::{TextLen, TextRange, TextSize};
use rustpython_parser::ast::{self, ExceptHandler, Expr, Keyword, Ranged, Stmt}; use rustpython_ast::{self as ast, ExceptHandler, Expr, Keyword, Ranged, Stmt};
use rustpython_parser::{lexer, Mode}; use rustpython_parser::{lexer, Mode};
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_python_ast::helpers; use ruff_python_codegen::Stylist;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist}; use ruff_python_index::Indexer;
use ruff_python_trivia::{is_python_whitespace, NewlineWithTrailingNewline, PythonWhitespace}; use ruff_python_trivia::{has_leading_content, is_python_whitespace, PythonWhitespace};
use ruff_source_file::{Locator, NewlineWithTrailingNewline};
use crate::autofix::codemods; use crate::autofix::codemods;
@ -41,11 +42,9 @@ pub(crate) fn delete_stmt(
if let Some(semicolon) = trailing_semicolon(stmt.end(), locator) { if let Some(semicolon) = trailing_semicolon(stmt.end(), locator) {
let next = next_stmt_break(semicolon, locator); let next = next_stmt_break(semicolon, locator);
Edit::deletion(stmt.start(), next) Edit::deletion(stmt.start(), next)
} else if helpers::has_leading_content(stmt.start(), locator) { } else if has_leading_content(stmt.start(), locator) {
Edit::range_deletion(stmt.range()) Edit::range_deletion(stmt.range())
} else if let Some(start) = } else if let Some(start) = indexer.preceded_by_continuations(stmt.start(), locator) {
helpers::preceded_by_continuations(stmt.start(), locator, indexer)
{
Edit::range_deletion(TextRange::new(start, stmt.end())) Edit::range_deletion(TextRange::new(start, stmt.end()))
} else { } else {
let range = locator.full_lines_range(stmt.range()); let range = locator.full_lines_range(stmt.range());
@ -296,10 +295,10 @@ fn next_stmt_break(semicolon: TextSize, locator: &Locator) -> TextSize {
mod tests { mod tests {
use anyhow::Result; use anyhow::Result;
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use rustpython_parser::ast::{Ranged, Suite}; use rustpython_ast::{Ranged, Suite};
use rustpython_parser::Parse; use rustpython_parser::Parse;
use ruff_python_ast::source_code::Locator; use ruff_source_file::Locator;
use crate::autofix::edits::{next_stmt_break, trailing_semicolon}; use crate::autofix::edits::{next_stmt_break, trailing_semicolon};

View file

@ -5,7 +5,7 @@ use ruff_text_size::{TextLen, TextRange, TextSize};
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use ruff_diagnostics::{Diagnostic, Edit, Fix, IsolationLevel}; use ruff_diagnostics::{Diagnostic, Edit, Fix, IsolationLevel};
use ruff_python_ast::source_code::Locator; use ruff_source_file::Locator;
use crate::autofix::source_map::SourceMap; use crate::autofix::source_map::SourceMap;
use crate::linter::FixTable; use crate::linter::FixTable;
@ -146,7 +146,7 @@ mod tests {
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_diagnostics::Fix; use ruff_diagnostics::Fix;
use ruff_python_ast::source_code::Locator; use ruff_source_file::Locator;
use crate::autofix::source_map::SourceMarker; use crate::autofix::source_map::SourceMarker;
use crate::autofix::{apply_fixes, FixResult}; use crate::autofix::{apply_fixes, FixResult};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Arg, Ranged}; use rustpython_ast::{Arg, Ranged};
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Arguments; use rustpython_ast::Arguments;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Comprehension; use rustpython_ast::Comprehension;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Stmt}; use rustpython_ast::{self as ast, Stmt};
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,6 +1,6 @@
use ruff_python_ast::str::raw_contents_range; use ruff_python_ast::str::raw_contents_range;
use ruff_text_size::TextRange; use ruff_text_size::TextRange;
use rustpython_parser::ast::Ranged; use rustpython_ast::Ranged;
use ruff_python_semantic::{BindingKind, ContextualizedDefinition, Export}; use ruff_python_semantic::{BindingKind, ContextualizedDefinition, Export};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, ExceptHandler, Ranged}; use rustpython_ast::{self as ast, ExceptHandler, Ranged};
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::registry::Rule; use crate::registry::Rule;

View file

@ -1,5 +1,5 @@
use rustpython_ast::{self as ast, Constant, Expr, ExprContext, Operator, Ranged};
use rustpython_format::cformat::{CFormatError, CFormatErrorType}; use rustpython_format::cformat::{CFormatError, CFormatErrorType};
use rustpython_parser::ast::{self, Constant, Expr, ExprContext, Operator, Ranged};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Suite; use rustpython_ast::Suite;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Expr, Ranged, Stmt}; use rustpython_ast::{self as ast, Expr, Ranged, Stmt};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::helpers; use ruff_python_ast::helpers;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Stmt; use rustpython_ast::Stmt;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;
use crate::codes::Rule; use crate::codes::Rule;

View file

@ -1,5 +1,5 @@
use ruff_text_size::TextRange; use ruff_text_size::TextRange;
use rustpython_parser::ast::Expr; use rustpython_ast::Expr;
use ruff_python_semantic::{ScopeId, Snapshot}; use ruff_python_semantic::{ScopeId, Snapshot};

View file

@ -31,20 +31,21 @@ use std::path::Path;
use itertools::Itertools; use itertools::Itertools;
use log::error; use log::error;
use ruff_text_size::{TextRange, TextSize}; use ruff_text_size::{TextRange, TextSize};
use rustpython_parser::ast::{ use rustpython_ast::{
self, Arg, ArgWithDefault, Arguments, Comprehension, Constant, ElifElseClause, ExceptHandler, self as ast, Arg, ArgWithDefault, Arguments, Comprehension, Constant, ElifElseClause,
Expr, ExprContext, Keyword, Pattern, Ranged, Stmt, Suite, UnaryOp, ExceptHandler, Expr, ExprContext, Keyword, Pattern, Ranged, Stmt, Suite, UnaryOp,
}; };
use ruff_diagnostics::{Diagnostic, IsolationLevel}; use ruff_diagnostics::{Diagnostic, IsolationLevel};
use ruff_python_ast::all::{extract_all_names, DunderAllFlags}; use ruff_python_ast::all::{extract_all_names, DunderAllFlags};
use ruff_python_ast::helpers::{extract_handled_exceptions, to_module_path}; use ruff_python_ast::helpers::{extract_handled_exceptions, to_module_path};
use ruff_python_ast::identifier::Identifier; use ruff_python_ast::identifier::Identifier;
use ruff_python_ast::source_code::{Generator, Indexer, Locator, Quote, Stylist};
use ruff_python_ast::str::trailing_quote; use ruff_python_ast::str::trailing_quote;
use ruff_python_ast::typing::{parse_type_annotation, AnnotationKind};
use ruff_python_ast::visitor::{walk_except_handler, walk_pattern, Visitor}; use ruff_python_ast::visitor::{walk_except_handler, walk_pattern, Visitor};
use ruff_python_ast::{helpers, str, visitor}; use ruff_python_ast::{helpers, str, visitor};
use ruff_python_codegen::{Generator, Quote, Stylist};
use ruff_python_index::Indexer;
use ruff_python_parser::typing::{parse_type_annotation, AnnotationKind};
use ruff_python_semantic::analyze::{typing, visibility}; use ruff_python_semantic::analyze::{typing, visibility};
use ruff_python_semantic::{ use ruff_python_semantic::{
BindingFlags, BindingId, BindingKind, Exceptions, Export, FromImport, Globals, Import, Module, BindingFlags, BindingId, BindingKind, Exceptions, Export, FromImport, Globals, Import, Module,
@ -52,6 +53,7 @@ use ruff_python_semantic::{
}; };
use ruff_python_stdlib::builtins::{BUILTINS, MAGIC_GLOBALS}; use ruff_python_stdlib::builtins::{BUILTINS, MAGIC_GLOBALS};
use ruff_python_stdlib::path::is_python_stub_file; use ruff_python_stdlib::path::is_python_stub_file;
use ruff_source_file::Locator;
use crate::checkers::ast::deferred::Deferred; use crate::checkers::ast::deferred::Deferred;
use crate::docstrings::extraction::ExtractionTarget; use crate::docstrings::extraction::ExtractionTarget;
@ -1690,7 +1692,9 @@ impl<'a> Checker<'a> {
while !self.deferred.string_type_definitions.is_empty() { while !self.deferred.string_type_definitions.is_empty() {
let type_definitions = std::mem::take(&mut self.deferred.string_type_definitions); let type_definitions = std::mem::take(&mut self.deferred.string_type_definitions);
for (range, value, snapshot) in type_definitions { for (range, value, snapshot) in type_definitions {
if let Ok((expr, kind)) = parse_type_annotation(value, range, self.locator) { if let Ok((expr, kind)) =
parse_type_annotation(value, range, self.locator.contents())
{
let expr = allocator.alloc(expr); let expr = allocator.alloc(expr);
self.semantic.restore(snapshot); self.semantic.restore(snapshot);

View file

@ -2,14 +2,16 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::path::Path; use std::path::Path;
use rustpython_parser::ast::{self, Ranged, Stmt, Suite}; use rustpython_ast::{self as ast, Ranged, Stmt, Suite};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::helpers::to_module_path; use ruff_python_ast::helpers::to_module_path;
use ruff_python_ast::imports::{ImportMap, ModuleImport}; use ruff_python_ast::imports::{ImportMap, ModuleImport};
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
use ruff_python_ast::statement_visitor::StatementVisitor; use ruff_python_ast::statement_visitor::StatementVisitor;
use ruff_python_codegen::Stylist;
use ruff_python_index::Indexer;
use ruff_python_stdlib::path::is_python_stub_file; use ruff_python_stdlib::path::is_python_stub_file;
use ruff_source_file::Locator;
use crate::directives::IsortDirectives; use crate::directives::IsortDirectives;
use crate::registry::Rule; use crate::registry::Rule;

View file

@ -2,8 +2,9 @@ use ruff_text_size::TextRange;
use rustpython_parser::lexer::LexResult; use rustpython_parser::lexer::LexResult;
use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_diagnostics::{Diagnostic, DiagnosticKind};
use ruff_python_ast::source_code::{Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_ast::token_kind::TokenKind; use ruff_python_parser::token_kind::TokenKind;
use ruff_source_file::Locator;
use crate::registry::{AsRule, Rule}; use crate::registry::{AsRule, Rule};
use crate::rules::pycodestyle::rules::logical_lines::{ use crate::rules::pycodestyle::rules::logical_lines::{

View file

@ -4,10 +4,10 @@ use std::path::Path;
use itertools::Itertools; use itertools::Itertools;
use ruff_text_size::{TextLen, TextRange, TextSize}; use ruff_text_size::{TextLen, TextRange, TextSize};
use rustpython_parser::ast::Ranged; use rustpython_ast::Ranged;
use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_diagnostics::{Diagnostic, Edit, Fix};
use ruff_python_ast::source_code::Locator; use ruff_source_file::Locator;
use crate::noqa; use crate::noqa;
use crate::noqa::{Directive, FileExemption, NoqaDirectives, NoqaMapping}; use crate::noqa::{Directive, FileExemption, NoqaDirectives, NoqaMapping};

View file

@ -2,8 +2,9 @@
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_trivia::UniversalNewlines; use ruff_python_index::Indexer;
use ruff_source_file::{Locator, UniversalNewlines};
use crate::registry::Rule; use crate::registry::Rule;
use crate::rules::flake8_copyright::rules::missing_copyright_notice; use crate::rules::flake8_copyright::rules::missing_copyright_notice;
@ -121,7 +122,9 @@ mod tests {
use rustpython_parser::lexer::lex; use rustpython_parser::lexer::lex;
use rustpython_parser::Mode; use rustpython_parser::Mode;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::line_width::LineLength; use crate::line_width::LineLength;
use crate::registry::Rule; use crate::registry::Rule;

View file

@ -6,7 +6,8 @@ use rustpython_parser::lexer::LexResult;
use rustpython_parser::Tok; use rustpython_parser::Tok;
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{Indexer, Locator}; use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::directives::TodoComment; use crate::directives::TodoComment;
use crate::lex::docstring_detection::StateMachine; use crate::lex::docstring_detection::StateMachine;

View file

@ -7,7 +7,8 @@ use ruff_text_size::{TextLen, TextRange, TextSize};
use rustpython_parser::lexer::LexResult; use rustpython_parser::lexer::LexResult;
use rustpython_parser::Tok; use rustpython_parser::Tok;
use ruff_python_ast::source_code::{Indexer, Locator}; use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::noqa::NoqaMapping; use crate::noqa::NoqaMapping;
use crate::settings::Settings; use crate::settings::Settings;
@ -352,7 +353,8 @@ mod tests {
use rustpython_parser::lexer::LexResult; use rustpython_parser::lexer::LexResult;
use rustpython_parser::{lexer, Mode}; use rustpython_parser::{lexer, Mode};
use ruff_python_ast::source_code::{Indexer, Locator}; use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::directives::{ use crate::directives::{
extract_isort_directives, extract_noqa_line_for, TodoDirective, TodoDirectiveKind, extract_isort_directives, extract_noqa_line_for, TodoDirective, TodoDirectiveKind,

View file

@ -4,13 +4,12 @@
use std::iter::FusedIterator; use std::iter::FusedIterator;
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use rustpython_parser::ast::{self, Constant, Expr, Ranged, Stmt, Suite}; use rustpython_ast::{self as ast, Constant, Expr, Ranged, Stmt, Suite};
use rustpython_parser::lexer::LexResult; use rustpython_parser::lexer::LexResult;
use rustpython_parser::Tok; use rustpython_parser::Tok;
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
use ruff_python_trivia::UniversalNewlineIterator; use ruff_source_file::{Locator, UniversalNewlineIterator};
/// Extract doc lines (standalone comments) from a token sequence. /// Extract doc lines (standalone comments) from a token sequence.
pub(crate) fn doc_lines_from_tokens(lxr: &[LexResult]) -> DocLines { pub(crate) fn doc_lines_from_tokens(lxr: &[LexResult]) -> DocLines {

View file

@ -1,6 +1,6 @@
//! Extract docstrings from an AST. //! Extract docstrings from an AST.
use rustpython_parser::ast::{self, Constant, Expr, Stmt}; use rustpython_ast::{self as ast, Constant, Expr, Stmt};
use ruff_python_semantic::{Definition, DefinitionId, Definitions, Member, MemberKind}; use ruff_python_semantic::{Definition, DefinitionId, Definitions, Member, MemberKind};

View file

@ -2,7 +2,7 @@ use std::fmt::{Debug, Formatter};
use std::ops::Deref; use std::ops::Deref;
use ruff_text_size::{TextRange, TextSize}; use ruff_text_size::{TextRange, TextSize};
use rustpython_parser::ast::{Expr, Ranged}; use rustpython_ast::{Expr, Ranged};
use ruff_python_semantic::Definition; use ruff_python_semantic::Definition;

View file

@ -5,7 +5,7 @@ use ruff_python_ast::docstrings::{leading_space, leading_words};
use ruff_text_size::{TextLen, TextRange, TextSize}; use ruff_text_size::{TextLen, TextRange, TextSize};
use strum_macros::EnumIter; use strum_macros::EnumIter;
use ruff_python_trivia::{Line, UniversalNewlineIterator, UniversalNewlines}; use ruff_source_file::{Line, UniversalNewlineIterator, UniversalNewlines};
use crate::docstrings::styles::SectionStyle; use crate::docstrings::styles::SectionStyle;
use crate::docstrings::{Docstring, DocstringBody}; use crate::docstrings::{Docstring, DocstringBody};

View file

@ -2,14 +2,14 @@
use std::ops::Add; use std::ops::Add;
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use rustpython_parser::ast::{Ranged, Stmt}; use rustpython_ast::{Ranged, Stmt};
use rustpython_parser::{lexer, Mode, Tok}; use rustpython_parser::{lexer, Mode, Tok};
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_python_ast::helpers::is_docstring_stmt; use ruff_python_ast::helpers::is_docstring_stmt;
use ruff_python_ast::source_code::{Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_trivia::{PythonWhitespace, UniversalNewlineIterator}; use ruff_python_trivia::{textwrap::indent, PythonWhitespace};
use ruff_textwrap::indent; use ruff_source_file::{Locator, UniversalNewlineIterator};
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub(super) enum Placement<'a> { pub(super) enum Placement<'a> {
@ -300,12 +300,12 @@ fn match_leading_semicolon(s: &str) -> Option<TextSize> {
mod tests { mod tests {
use anyhow::Result; use anyhow::Result;
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use rustpython_parser::ast::Suite; use rustpython_ast::Suite;
use rustpython_parser::lexer::LexResult; use rustpython_parser::lexer::LexResult;
use rustpython_parser::Parse; use rustpython_parser::Parse;
use ruff_python_ast::source_code::{Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_trivia::LineEnding; use ruff_source_file::{LineEnding, Locator};
use super::Insertion; use super::Insertion;
@ -313,7 +313,7 @@ mod tests {
fn start_of_file() -> Result<()> { fn start_of_file() -> Result<()> {
fn insert(contents: &str) -> Result<Insertion> { fn insert(contents: &str) -> Result<Insertion> {
let program = Suite::parse(contents, "<filename>")?; let program = Suite::parse(contents, "<filename>")?;
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(contents); let tokens: Vec<LexResult> = ruff_python_parser::tokenize(contents);
let locator = Locator::new(contents); let locator = Locator::new(contents);
let stylist = Stylist::from_tokens(&tokens, &locator); let stylist = Stylist::from_tokens(&tokens, &locator);
Ok(Insertion::start_of_file(&program, &locator, &stylist)) Ok(Insertion::start_of_file(&program, &locator, &stylist))
@ -424,7 +424,7 @@ x = 1
#[test] #[test]
fn start_of_block() { fn start_of_block() {
fn insert(contents: &str, offset: TextSize) -> Insertion { fn insert(contents: &str, offset: TextSize) -> Insertion {
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(contents); let tokens: Vec<LexResult> = ruff_python_parser::tokenize(contents);
let locator = Locator::new(contents); let locator = Locator::new(contents);
let stylist = Stylist::from_tokens(&tokens, &locator); let stylist = Stylist::from_tokens(&tokens, &locator);
Insertion::start_of_block(offset, &locator, &stylist) Insertion::start_of_block(offset, &locator, &stylist)

View file

@ -8,13 +8,14 @@ use std::error::Error;
use anyhow::Result; use anyhow::Result;
use libcst_native::{ImportAlias, Name, NameOrAttribute}; use libcst_native::{ImportAlias, Name, NameOrAttribute};
use ruff_text_size::TextSize; use ruff_text_size::TextSize;
use rustpython_parser::ast::{self, Ranged, Stmt, Suite}; use rustpython_ast::{self as ast, Ranged, Stmt, Suite};
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_python_ast::imports::{AnyImport, Import, ImportFrom}; use ruff_python_ast::imports::{AnyImport, Import, ImportFrom};
use ruff_python_ast::source_code::{Locator, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_semantic::SemanticModel; use ruff_python_semantic::SemanticModel;
use ruff_textwrap::indent; use ruff_python_trivia::textwrap::indent;
use ruff_source_file::Locator;
use crate::autofix; use crate::autofix;
use crate::autofix::codemods::CodegenStylist; use crate::autofix::codemods::CodegenStylist;

View file

@ -10,7 +10,7 @@ use serde::Serialize;
use serde_json::error::Category; use serde_json::error::Category;
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_trivia::{NewlineWithTrailingNewline, UniversalNewlineIterator}; use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlineIterator};
use ruff_text_size::{TextRange, TextSize}; use ruff_text_size::{TextRange, TextSize};
use rustpython_parser::lexer::lex; use rustpython_parser::lexer::lex;
use rustpython_parser::Mode; use rustpython_parser::Mode;

View file

@ -5,7 +5,6 @@
//! //!
//! [Ruff]: https://github.com/astral-sh/ruff //! [Ruff]: https://github.com/astral-sh/ruff
pub use ruff_python_ast::source_code::round_trip;
pub use rule_selector::RuleSelector; pub use rule_selector::RuleSelector;
pub use rules::pycodestyle::rules::IOError; pub use rules::pycodestyle::rules::IOError;

View file

@ -12,8 +12,10 @@ use rustpython_parser::ParseError;
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::imports::ImportMap; use ruff_python_ast::imports::ImportMap;
use ruff_python_ast::source_code::{Indexer, Locator, SourceFileBuilder, Stylist}; use ruff_python_codegen::Stylist;
use ruff_python_index::Indexer;
use ruff_python_stdlib::path::is_python_stub_file; use ruff_python_stdlib::path::is_python_stub_file;
use ruff_source_file::{Locator, SourceFileBuilder};
use crate::autofix::{fix_file, FixResult}; use crate::autofix::{fix_file, FixResult};
use crate::checkers::ast::check_ast; use crate::checkers::ast::check_ast;
@ -136,7 +138,7 @@ pub fn check_path(
.iter_enabled() .iter_enabled()
.any(|rule_code| rule_code.lint_source().is_imports()); .any(|rule_code| rule_code.lint_source().is_imports());
if use_ast || use_imports || use_doc_lines { if use_ast || use_imports || use_doc_lines {
match ruff_rustpython::parse_program_tokens(tokens, &path.to_string_lossy()) { match ruff_python_parser::parse_program_tokens(tokens, &path.to_string_lossy()) {
Ok(python_ast) => { Ok(python_ast) => {
if use_ast { if use_ast {
diagnostics.extend(check_ast( diagnostics.extend(check_ast(
@ -258,7 +260,7 @@ pub fn add_noqa_to_path(path: &Path, package: Option<&Path>, settings: &Settings
let contents = std::fs::read_to_string(path)?; let contents = std::fs::read_to_string(path)?;
// Tokenize once. // Tokenize once.
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(&contents); let tokens: Vec<LexResult> = ruff_python_parser::tokenize(&contents);
// Map row and column locations to byte slices (lazily). // Map row and column locations to byte slices (lazily).
let locator = Locator::new(&contents); let locator = Locator::new(&contents);
@ -326,7 +328,7 @@ pub fn lint_only(
source_kind: Option<&SourceKind>, source_kind: Option<&SourceKind>,
) -> LinterResult<(Vec<Message>, Option<ImportMap>)> { ) -> LinterResult<(Vec<Message>, Option<ImportMap>)> {
// Tokenize once. // Tokenize once.
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(contents); let tokens: Vec<LexResult> = ruff_python_parser::tokenize(contents);
// Map row and column locations to byte slices (lazily). // Map row and column locations to byte slices (lazily).
let locator = Locator::new(contents); let locator = Locator::new(contents);
@ -418,7 +420,7 @@ pub fn lint_fix<'a>(
// Continuously autofix until the source code stabilizes. // Continuously autofix until the source code stabilizes.
loop { loop {
// Tokenize once. // Tokenize once.
let tokens: Vec<LexResult> = ruff_rustpython::tokenize(&transformed); let tokens: Vec<LexResult> = ruff_python_parser::tokenize(&transformed);
// Map row and column locations to byte slices (lazily). // Map row and column locations to byte slices (lazily).
let locator = Locator::new(&transformed); let locator = Locator::new(&transformed);

View file

@ -9,7 +9,7 @@ use log::Level;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use rustpython_parser::{ParseError, ParseErrorType}; use rustpython_parser::{ParseError, ParseErrorType};
use ruff_python_ast::source_code::{OneIndexed, SourceCode, SourceLocation}; use ruff_source_file::{OneIndexed, SourceCode, SourceLocation};
use crate::fs; use crate::fs;
use crate::jupyter::Notebook; use crate::jupyter::Notebook;

View file

@ -1,6 +1,6 @@
use std::io::Write; use std::io::Write;
use ruff_python_ast::source_code::SourceLocation; use ruff_source_file::SourceLocation;
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};
use crate::registry::AsRule; use crate::registry::AsRule;

View file

@ -7,7 +7,7 @@ use ruff_text_size::{TextRange, TextSize};
use similar::{ChangeTag, TextDiff}; use similar::{ChangeTag, TextDiff};
use ruff_diagnostics::{Applicability, Fix}; use ruff_diagnostics::{Applicability, Fix};
use ruff_python_ast::source_code::{OneIndexed, SourceFile}; use ruff_source_file::{OneIndexed, SourceFile};
use crate::message::Message; use crate::message::Message;

View file

@ -1,6 +1,6 @@
use std::io::Write; use std::io::Write;
use ruff_python_ast::source_code::SourceLocation; use ruff_source_file::SourceLocation;
use crate::fs::relativize_path; use crate::fs::relativize_path;
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};

View file

@ -6,7 +6,7 @@ use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use serde_json::json; use serde_json::json;
use ruff_python_ast::source_code::SourceLocation; use ruff_source_file::SourceLocation;
use crate::fs::{relativize_path, relativize_path_to}; use crate::fs::{relativize_path, relativize_path_to};
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};

View file

@ -4,7 +4,7 @@ use std::num::NonZeroUsize;
use colored::Colorize; use colored::Colorize;
use ruff_python_ast::source_code::OneIndexed; use ruff_source_file::OneIndexed;
use crate::fs::relativize_path; use crate::fs::relativize_path;
use crate::jupyter::{JupyterIndex, Notebook}; use crate::jupyter::{JupyterIndex, Notebook};

View file

@ -5,7 +5,7 @@ use serde::{Serialize, Serializer};
use serde_json::{json, Value}; use serde_json::{json, Value};
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_python_ast::source_code::SourceCode; use ruff_source_file::SourceCode;
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};
use crate::registry::AsRule; use crate::registry::AsRule;

View file

@ -3,7 +3,7 @@ use std::path::Path;
use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite};
use ruff_python_ast::source_code::SourceLocation; use ruff_source_file::SourceLocation;
use crate::message::{ use crate::message::{
group_messages_by_filename, Emitter, EmitterContext, Message, MessageWithLocation, group_messages_by_filename, Emitter, EmitterContext, Message, MessageWithLocation,

View file

@ -16,7 +16,7 @@ pub use json_lines::JsonLinesEmitter;
pub use junit::JunitEmitter; pub use junit::JunitEmitter;
pub use pylint::PylintEmitter; pub use pylint::PylintEmitter;
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Fix}; use ruff_diagnostics::{Diagnostic, DiagnosticKind, Fix};
use ruff_python_ast::source_code::{SourceFile, SourceLocation}; use ruff_source_file::{SourceFile, SourceLocation};
pub use text::TextEmitter; pub use text::TextEmitter;
mod azure; mod azure;
@ -155,7 +155,7 @@ mod tests {
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Edit, Fix}; use ruff_diagnostics::{Diagnostic, DiagnosticKind, Edit, Fix};
use ruff_python_ast::source_code::SourceFileBuilder; use ruff_source_file::SourceFileBuilder;
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};

View file

@ -1,6 +1,6 @@
use std::io::Write; use std::io::Write;
use ruff_python_ast::source_code::OneIndexed; use ruff_source_file::OneIndexed;
use crate::fs::relativize_path; use crate::fs::relativize_path;
use crate::message::{Emitter, EmitterContext, Message}; use crate::message::{Emitter, EmitterContext, Message};

View file

@ -8,7 +8,7 @@ use bitflags::bitflags;
use colored::Colorize; use colored::Colorize;
use ruff_text_size::{TextRange, TextSize}; use ruff_text_size::{TextRange, TextSize};
use ruff_python_ast::source_code::{OneIndexed, SourceLocation}; use ruff_source_file::{OneIndexed, SourceLocation};
use crate::fs::relativize_path; use crate::fs::relativize_path;
use crate::jupyter::{JupyterIndex, Notebook}; use crate::jupyter::{JupyterIndex, Notebook};

View file

@ -9,11 +9,10 @@ use anyhow::Result;
use itertools::Itertools; use itertools::Itertools;
use log::warn; use log::warn;
use ruff_text_size::{TextLen, TextRange, TextSize}; use ruff_text_size::{TextLen, TextRange, TextSize};
use rustpython_parser::ast::Ranged; use rustpython_ast::Ranged;
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::Locator; use ruff_source_file::{LineEnding, Locator};
use ruff_python_trivia::LineEnding;
use crate::codes::NoqaCode; use crate::codes::NoqaCode;
use crate::fs::relativize_path; use crate::fs::relativize_path;
@ -782,8 +781,7 @@ mod tests {
use ruff_text_size::{TextRange, TextSize}; use ruff_text_size::{TextRange, TextSize};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::Locator; use ruff_source_file::{LineEnding, Locator};
use ruff_python_trivia::LineEnding;
use crate::noqa::{add_noqa_inner, Directive, NoqaMapping, ParsedFileExemption}; use crate::noqa::{add_noqa_inner, Directive, NoqaMapping, ParsedFileExemption};
use crate::rules::pycodestyle::rules::AmbiguousVariableName; use crate::rules::pycodestyle::rules::AmbiguousVariableName;

View file

@ -5,7 +5,7 @@ use ruff_text_size::{TextRange, TextSize};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::SourceFile; use ruff_source_file::SourceFile;
use crate::message::Message; use crate::message::Message;
use crate::registry::Rule; use crate::registry::Rule;

View file

@ -1,10 +1,10 @@
use rustpython_ast::{Expr, Ranged};
use rustpython_parser::ast; use rustpython_parser::ast;
use rustpython_parser::ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::find_keyword; use ruff_python_ast::helpers::find_keyword;
use rustpython_parser::ast::Constant; use rustpython_ast::Constant;
use crate::checkers::ast::Checker; use crate::checkers::ast::Checker;

View file

@ -1,7 +1,7 @@
/// See: [eradicate.py](https://github.com/myint/eradicate/blob/98f199940979c94447a461d50d27862b118b282d/eradicate.py) /// See: [eradicate.py](https://github.com/myint/eradicate/blob/98f199940979c94447a461d50d27862b118b282d/eradicate.py)
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use rustpython_parser::ast::Suite; use rustpython_ast::Suite;
use rustpython_parser::Parse; use rustpython_parser::Parse;
static ALLOWLIST_REGEX: Lazy<Regex> = Lazy::new(|| { static ALLOWLIST_REGEX: Lazy<Regex> = Lazy::new(|| {

View file

@ -1,6 +1,7 @@
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::source_code::{Indexer, Locator}; use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::registry::Rule; use crate::registry::Rule;
use crate::settings::Settings; use crate::settings::Settings;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Expr; use rustpython_ast::Expr;
use ruff_python_semantic::SemanticModel; use ruff_python_semantic::SemanticModel;

View file

@ -1,5 +1,5 @@
use num_bigint::BigInt; use num_bigint::BigInt;
use rustpython_parser::ast::{self, CmpOp, Constant, Expr, Ranged}; use rustpython_ast::{self as ast, CmpOp, Constant, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Ranged}; use rustpython_ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use num_bigint::BigInt; use num_bigint::BigInt;
use rustpython_parser::ast::{self, Constant, Expr, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,9 +1,9 @@
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use rustpython_parser::ast::{Ranged, Stmt}; use rustpython_ast::{Ranged, Stmt};
use rustpython_parser::{lexer, Mode, Tok}; use rustpython_parser::{lexer, Mode, Tok};
use ruff_diagnostics::Edit; use ruff_diagnostics::Edit;
use ruff_python_ast::source_code::Locator; use ruff_source_file::Locator;
/// ANN204 /// ANN204
pub(crate) fn add_return_annotation( pub(crate) fn add_return_annotation(

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Arguments, Expr, Stmt}; use rustpython_ast::{self as ast, Arguments, Expr, Stmt};
use ruff_python_ast::cast; use ruff_python_ast::cast;
use ruff_python_semantic::analyze::visibility; use ruff_python_semantic::analyze::visibility;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, ArgWithDefault, Constant, Expr, Ranged, Stmt}; use rustpython_ast::{self as ast, ArgWithDefault, Constant, Expr, Ranged, Stmt};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix, Violation}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};
@ -6,7 +6,7 @@ use ruff_python_ast::cast;
use ruff_python_ast::helpers::ReturnStatementVisitor; use ruff_python_ast::helpers::ReturnStatementVisitor;
use ruff_python_ast::identifier::Identifier; use ruff_python_ast::identifier::Identifier;
use ruff_python_ast::statement_visitor::StatementVisitor; use ruff_python_ast::statement_visitor::StatementVisitor;
use ruff_python_ast::typing::parse_type_annotation; use ruff_python_parser::typing::parse_type_annotation;
use ruff_python_semantic::analyze::visibility; use ruff_python_semantic::analyze::visibility;
use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_semantic::{Definition, Member, MemberKind};
use ruff_python_stdlib::typing::simple_magic_return_type; use ruff_python_stdlib::typing::simple_magic_return_type;
@ -462,7 +462,8 @@ fn check_dynamically_typed<F>(
}) = annotation }) = annotation
{ {
// Quoted annotations // Quoted annotations
if let Ok((parsed_annotation, _)) = parse_type_annotation(string, *range, checker.locator()) if let Ok((parsed_annotation, _)) =
parse_type_annotation(string, *range, checker.locator().contents())
{ {
if type_hint_resolves_to_any( if type_hint_resolves_to_any(
&parsed_annotation, &parsed_annotation,

View file

@ -1,5 +1,5 @@
use rustpython_ast::{Expr, Ranged};
use rustpython_parser::ast; use rustpython_parser::ast;
use rustpython_parser::ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use rustpython_ast::{Expr, Ranged};
use rustpython_parser::ast; use rustpython_parser::ast;
use rustpython_parser::ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use rustpython_ast::{Expr, Ranged};
use rustpython_parser::ast; use rustpython_parser::ast;
use rustpython_parser::ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,6 +1,6 @@
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use rustpython_parser::ast::{self, Constant, Expr}; use rustpython_ast::{self as ast, Constant, Expr};
use ruff_python_semantic::SemanticModel; use ruff_python_semantic::SemanticModel;

View file

@ -1,5 +1,5 @@
use ruff_text_size::{TextLen, TextRange}; use ruff_text_size::{TextLen, TextRange};
use rustpython_parser::ast::{Ranged, Stmt}; use rustpython_ast::{Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use num_traits::ToPrimitive; use num_traits::ToPrimitive;
use rustpython_parser::ast::{self, Constant, Expr, Keyword, Operator, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Keyword, Operator, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Ranged}; use rustpython_ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Arg, ArgWithDefault, Arguments, Expr, Ranged}; use rustpython_ast::{Arg, ArgWithDefault, Arguments, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Keyword, Ranged}; use rustpython_ast::{Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Constant, Expr, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,6 +1,6 @@
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use rustpython_parser::ast::{self, Expr, Operator, Ranged}; use rustpython_ast::{self as ast, Expr, Operator, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Ranged}; use rustpython_ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Keyword, Ranged}; use rustpython_ast::{Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use ruff_python_ast::helpers::find_keyword; use ruff_python_ast::helpers::find_keyword;
use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Keyword, Ranged}; use rustpython_ast::{Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Ranged}; use rustpython_ast::{Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Keyword, Ranged}; use rustpython_ast::{Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Keyword, Ranged}; use rustpython_ast::{Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,6 +1,6 @@
//! Checks relating to shell injection. //! Checks relating to shell injection.
use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use num_traits::{One, Zero}; use num_traits::{One, Zero};
use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{Expr, Keyword, Ranged}; use rustpython_ast::{Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,7 +1,7 @@
//! Check for calls to suspicious functions, or calls into suspicious modules. //! Check for calls to suspicious functions, or calls into suspicious modules.
//! //!
//! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html> //! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html>
use rustpython_parser::ast::{self, Expr, Ranged}; use rustpython_ast::{self as ast, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation}; use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{ExceptHandler, Expr, Ranged, Stmt}; use rustpython_ast::{ExceptHandler, Expr, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{ExceptHandler, Expr, Ranged, Stmt}; use rustpython_ast::{ExceptHandler, Expr, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Expr, Keyword, Ranged}; use rustpython_ast::{self as ast, Expr, Keyword, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Expr, Ranged, Stmt}; use rustpython_ast::{self as ast, Expr, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Constant, Expr, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_diagnostics::{Diagnostic, DiagnosticKind};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{ArgWithDefault, Arguments, Decorator}; use rustpython_ast::{ArgWithDefault, Arguments, Decorator};
use ruff_diagnostics::Violation; use ruff_diagnostics::Violation;
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::Expr; use rustpython_ast::Expr;
use ruff_diagnostics::Violation; use ruff_diagnostics::Violation;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, ArgWithDefault, Arguments, Constant, Decorator, Expr, Ranged}; use rustpython_ast::{self as ast, ArgWithDefault, Arguments, Constant, Decorator, Expr, Ranged};
use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Diagnostic;
use ruff_diagnostics::Violation; use ruff_diagnostics::Violation;

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged, Stmt}; use rustpython_ast::{self as ast, Constant, Expr, Keyword, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use ruff_text_size::TextRange; use ruff_text_size::TextRange;
use rustpython_parser::ast::{self, Expr, ExprContext, Ranged, Stmt}; use rustpython_ast::{self as ast, Expr, ExprContext, Ranged, Stmt};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
use rustpython_parser::ast::{self, Expr, Ranged, WithItem}; use rustpython_ast::{self as ast, Expr, Ranged, WithItem};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Expr, Ranged}; use rustpython_ast::{self as ast, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Decorator, Expr, Ranged}; use rustpython_ast::{self as ast, Decorator, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,7 +1,7 @@
use itertools::Itertools; use itertools::Itertools;
use ruff_text_size::TextRange; use ruff_text_size::TextRange;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use rustpython_parser::ast::{self, ExceptHandler, Expr, ExprContext, Ranged}; use rustpython_ast::{self as ast, ExceptHandler, Expr, ExprContext, Ranged};
use ruff_diagnostics::{AlwaysAutofixableViolation, Violation}; use ruff_diagnostics::{AlwaysAutofixableViolation, Violation};
use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_diagnostics::{Diagnostic, Edit, Fix};

View file

@ -1,5 +1,5 @@
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use rustpython_parser::ast::{self, Expr, Ranged}; use rustpython_ast::{self as ast, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use rustpython_parser::ast::{self, Ranged}; use rustpython_ast::{self as ast, Ranged};
use rustpython_parser::ast::{ExceptHandler, Expr}; use rustpython_ast::{ExceptHandler, Expr};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,6 +1,6 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use rustpython_parser::ast::{self, ExceptHandler, Expr, Ranged}; use rustpython_ast::{self as ast, ExceptHandler, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Stmt}; use rustpython_ast::{self as ast, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use ruff_text_size::TextRange; use ruff_text_size::TextRange;
use rustpython_parser::ast::{self, ArgWithDefault, Arguments, Expr, Ranged}; use rustpython_ast::{self as ast, ArgWithDefault, Arguments, Expr, Ranged};
use ruff_diagnostics::Violation; use ruff_diagnostics::Violation;
use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_diagnostics::{Diagnostic, DiagnosticKind};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Comprehension, Expr, ExprContext, Ranged, Stmt}; use rustpython_ast::{self as ast, Comprehension, Expr, ExprContext, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Constant, Expr, Ranged}; use rustpython_ast::{self as ast, Constant, Expr, Ranged};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,4 +1,4 @@
use rustpython_parser::ast::{self, Ranged, Stmt}; use rustpython_ast::{self as ast, Ranged, Stmt};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

View file

@ -1,5 +1,5 @@
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use rustpython_parser::ast::{self, ArgWithDefault, Expr, Ranged}; use rustpython_ast::{self as ast, ArgWithDefault, Expr, Ranged};
use ruff_diagnostics::{Diagnostic, Violation}; use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation}; use ruff_macros::{derive_message_formats, violation};

Some files were not shown because too many files have changed in this diff Show more