mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Create a rust_python_ast
crate (#3370)
This PR productionizes @MichaReiser's suggestion in https://github.com/charliermarsh/ruff/issues/1820#issuecomment-1440204423, by creating a separate crate for the `ast` module (`rust_python_ast`). This will enable us to further split up the `ruff` crate, as we'll be able to create (e.g.) separate sub-linter crates that have access to these common AST utilities. This was mostly a straightforward copy (with adjustments to module imports), as the few dependencies that _did_ require modifications were handled in #3366, #3367, and #3368.
This commit is contained in:
parent
a5d302fcbf
commit
bad6bdda1f
405 changed files with 1336 additions and 988 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -2000,6 +2000,7 @@ dependencies = [
|
|||
"result-like",
|
||||
"ruff_cache",
|
||||
"ruff_macros",
|
||||
"ruff_python_ast",
|
||||
"ruff_python_stdlib",
|
||||
"ruff_rustpython",
|
||||
"rustc-hash",
|
||||
|
@ -2120,6 +2121,28 @@ dependencies = [
|
|||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruff_python_ast"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"is-macro",
|
||||
"itertools",
|
||||
"log",
|
||||
"nohash-hasher",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"ruff_python_stdlib",
|
||||
"ruff_rustpython",
|
||||
"rustc-hash",
|
||||
"rustpython-common",
|
||||
"rustpython-parser",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruff_python_formatter"
|
||||
version = "0.0.0"
|
||||
|
|
|
@ -18,6 +18,7 @@ doctest = false
|
|||
[dependencies]
|
||||
ruff_cache = { path = "../ruff_cache" }
|
||||
ruff_macros = { path = "../ruff_macros" }
|
||||
ruff_python_ast = { path = "../ruff_python_ast" }
|
||||
ruff_python_stdlib = { path = "../ruff_python_stdlib" }
|
||||
ruff_rustpython = { path = "../ruff_rustpython" }
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ use libcst_native::{
|
|||
use rustpython_parser::ast::{ExcepthandlerKind, Expr, Keyword, Location, Stmt, StmtKind};
|
||||
use rustpython_parser::{lexer, Mode, Tok};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::ast::helpers::to_absolute;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::whitespace::LinesWithTrailingNewline;
|
||||
use crate::cst::helpers::compose_module_path;
|
||||
use crate::cst::matchers::match_module;
|
||||
use crate::fix::Fix;
|
||||
use crate::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::helpers;
|
||||
use ruff_python_ast::helpers::to_absolute;
|
||||
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_ast::whitespace::LinesWithTrailingNewline;
|
||||
|
||||
/// Determine if a body contains only a single statement, taking into account
|
||||
/// deleted.
|
||||
|
@ -451,7 +451,7 @@ mod tests {
|
|||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::autofix::helpers::{next_stmt_break, trailing_semicolon};
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
|
||||
#[test]
|
||||
fn find_semicolon() -> Result<()> {
|
||||
|
|
|
@ -4,11 +4,11 @@ use itertools::Itertools;
|
|||
use rustc_hash::FxHashMap;
|
||||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::fix::Fix;
|
||||
use crate::linter::FixTable;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
pub mod helpers;
|
||||
|
||||
|
@ -100,7 +100,7 @@ mod tests {
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::pycodestyle::rules::NoNewLineAtEndOfFile;
|
||||
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
|
||||
#[test]
|
||||
fn empty_file() {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use rustpython_parser::ast::{Expr, Stmt};
|
||||
|
||||
use crate::ast::types::RefEquality;
|
||||
use crate::ast::visibility::{Visibility, VisibleScope};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_ast::types::RefEquality;
|
||||
use ruff_python_ast::visibility::{Visibility, VisibleScope};
|
||||
|
||||
use crate::checkers::ast::AnnotationContext;
|
||||
use crate::docstrings::definition::Definition;
|
||||
use crate::Range;
|
||||
|
||||
type Context<'a> = (Vec<usize>, Vec<RefEquality<'a, Stmt>>);
|
||||
|
||||
|
|
|
@ -13,20 +13,25 @@ use rustpython_parser::ast::{
|
|||
Suite,
|
||||
};
|
||||
|
||||
use ruff_python_stdlib::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||
use ruff_python_stdlib::path::is_python_stub_file;
|
||||
|
||||
use crate::ast::context::Context;
|
||||
use crate::ast::helpers::{binding_range, extract_handled_exceptions, to_module_path, Exceptions};
|
||||
use crate::ast::operations::{extract_all_names, AllNamesFlags};
|
||||
use crate::ast::relocate::relocate_expr;
|
||||
use crate::ast::types::{
|
||||
use ruff_python_ast::context::Context;
|
||||
use ruff_python_ast::helpers::{
|
||||
binding_range, extract_handled_exceptions, to_module_path, Exceptions,
|
||||
};
|
||||
use ruff_python_ast::operations::{extract_all_names, AllNamesFlags};
|
||||
use ruff_python_ast::relocate::relocate_expr;
|
||||
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::types::{
|
||||
Binding, BindingKind, ClassDef, ExecutionContext, FunctionDef, Lambda, Node, Range,
|
||||
RefEquality, Scope, ScopeKind,
|
||||
};
|
||||
use crate::ast::typing::{match_annotated_subscript, Callable, SubscriptKind};
|
||||
use crate::ast::visitor::{walk_excepthandler, walk_pattern, Visitor};
|
||||
use crate::ast::{branch_detection, cast, helpers, operations, typing, visibility, visitor};
|
||||
use ruff_python_ast::typing::{match_annotated_subscript, Callable, SubscriptKind};
|
||||
use ruff_python_ast::visitor::{walk_excepthandler, walk_pattern, Visitor};
|
||||
use ruff_python_ast::{
|
||||
branch_detection, cast, helpers, operations, strings, typing, visibility, visitor,
|
||||
};
|
||||
use ruff_python_stdlib::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||
use ruff_python_stdlib::path::is_python_stub_file;
|
||||
|
||||
use crate::checkers::ast::deferred::Deferred;
|
||||
use crate::docstrings::definition::{
|
||||
transition_scope, Definition, DefinitionKind, Docstring, Documentable,
|
||||
|
@ -43,8 +48,7 @@ use crate::rules::{
|
|||
};
|
||||
use crate::settings::types::PythonVersion;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Indexer, Locator, Stylist};
|
||||
use crate::{ast, autofix, docstrings, noqa};
|
||||
use crate::{autofix, docstrings, noqa};
|
||||
|
||||
mod deferred;
|
||||
|
||||
|
@ -2127,7 +2131,7 @@ where
|
|||
StmtKind::If { test, body, orelse } => {
|
||||
self.visit_expr(test);
|
||||
|
||||
if flake8_type_checking::helpers::is_type_checking_block(self, test) {
|
||||
if flake8_type_checking::helpers::is_type_checking_block(&self.ctx, test) {
|
||||
if self.settings.rules.enabled(&Rule::EmptyTypeCheckingBlock) {
|
||||
flake8_type_checking::rules::empty_type_checking_block(self, stmt, body);
|
||||
}
|
||||
|
@ -5288,7 +5292,7 @@ impl<'a> Checker<'a> {
|
|||
Location::new(expr.location.row(), expr.location.column()),
|
||||
));
|
||||
|
||||
let body = ast::strings::raw_contents(contents);
|
||||
let body = strings::raw_contents(contents);
|
||||
let docstring = Docstring {
|
||||
kind: definition.kind,
|
||||
expr,
|
||||
|
|
|
@ -4,13 +4,13 @@ use std::path::Path;
|
|||
|
||||
use rustpython_parser::ast::Suite;
|
||||
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::directives::IsortDirectives;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::rules::isort;
|
||||
use crate::rules::isort::track::{Block, ImportTracker};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn check_imports(
|
||||
|
|
|
@ -5,7 +5,6 @@ use itertools::Itertools;
|
|||
use rustpython_parser::ast::Location;
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::rules::pycodestyle::logical_lines::{iter_logical_lines, TokenFlags};
|
||||
use crate::rules::pycodestyle::rules::{
|
||||
|
@ -15,7 +14,8 @@ use crate::rules::pycodestyle::rules::{
|
|||
whitespace_before_parameters,
|
||||
};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
use ruff_python_ast::source_code::{Locator, Stylist};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
/// Return the amount of indentation, expanding tabs to the next multiple of 8.
|
||||
fn expand_indent(mut line: &str) -> usize {
|
||||
|
@ -226,7 +226,7 @@ mod tests {
|
|||
use rustpython_parser::{lexer, Mode};
|
||||
|
||||
use crate::checkers::logical_lines::iter_logical_lines;
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
|
||||
#[test]
|
||||
fn split_logical_lines() {
|
||||
|
|
|
@ -4,7 +4,6 @@ use log::warn;
|
|||
use nohash_hasher::IntMap;
|
||||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::codes::NoqaCode;
|
||||
use crate::fix::Fix;
|
||||
use crate::noqa;
|
||||
|
@ -13,6 +12,7 @@ use crate::registry::{Diagnostic, DiagnosticKind, Rule};
|
|||
use crate::rule_redirects::get_redirect_target;
|
||||
use crate::rules::ruff::rules::{UnusedCodes, UnusedNOQA};
|
||||
use crate::settings::{flags, Settings};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
pub fn check_noqa(
|
||||
diagnostics: &mut Vec<Diagnostic>,
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::rules::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore};
|
|||
use crate::rules::pylint;
|
||||
use crate::rules::pyupgrade::rules::unnecessary_coding_comment;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::Stylist;
|
||||
use ruff_python_ast::source_code::Stylist;
|
||||
|
||||
pub fn check_physical_lines(
|
||||
path: &Path,
|
||||
|
@ -185,7 +185,7 @@ mod tests {
|
|||
use super::check_physical_lines;
|
||||
use crate::registry::Rule;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
use ruff_python_ast::source_code::{Locator, Stylist};
|
||||
|
||||
#[test]
|
||||
fn e501_non_ascii_char() {
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::rules::{
|
|||
pyupgrade, ruff,
|
||||
};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
|
||||
pub fn check_tokens(
|
||||
locator: &Locator,
|
||||
|
|
|
@ -7,8 +7,8 @@ use rustpython_parser::ast::{Constant, ExprKind, Stmt, StmtKind, Suite};
|
|||
use rustpython_parser::lexer::LexResult;
|
||||
use rustpython_parser::Tok;
|
||||
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use ruff_python_ast::visitor;
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
|
||||
/// Extract doc lines (standalone comments) from a token sequence.
|
||||
pub fn doc_lines_from_tokens(lxr: &[LexResult]) -> DocLines {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::ast::visibility::{
|
||||
use ruff_python_ast::visibility::{
|
||||
class_visibility, function_visibility, method_visibility, Modifier, Visibility, VisibleScope,
|
||||
};
|
||||
use rustpython_parser::ast::{Expr, Stmt};
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::visibility::{Modifier, VisibleScope};
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind, Documentable};
|
||||
use ruff_python_ast::visibility::{Modifier, VisibleScope};
|
||||
|
||||
/// Extract a docstring from a function or class body.
|
||||
pub fn docstring_from(suite: &[Stmt]) -> Option<&Expr> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use strum_macros::EnumIter;
|
||||
|
||||
use crate::ast::whitespace;
|
||||
use crate::docstrings::styles::SectionStyle;
|
||||
use ruff_python_ast::whitespace;
|
||||
|
||||
#[derive(EnumIter, PartialEq, Eq, Debug, Clone, Copy)]
|
||||
pub enum SectionKind {
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
//!
|
||||
//! [Ruff]: https://github.com/charliermarsh/ruff
|
||||
|
||||
pub use ast::types::Range;
|
||||
use cfg_if::cfg_if;
|
||||
pub use ruff_python_ast::source_code::round_trip;
|
||||
pub use ruff_python_ast::types::Range;
|
||||
pub use rule_selector::RuleSelector;
|
||||
pub use rules::pycodestyle::rules::IOError;
|
||||
pub use violation::{AutofixKind, Availability as AutofixAvailability};
|
||||
|
||||
mod ast;
|
||||
mod autofix;
|
||||
mod checkers;
|
||||
mod codes;
|
||||
|
@ -33,7 +33,6 @@ mod rule_redirects;
|
|||
mod rule_selector;
|
||||
mod rules;
|
||||
pub mod settings;
|
||||
pub mod source_code;
|
||||
mod violation;
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::rules::{
|
|||
use crate::settings::configuration::Configuration;
|
||||
use crate::settings::options::Options;
|
||||
use crate::settings::{defaults, flags, Settings};
|
||||
use crate::source_code::{Indexer, Locator, Stylist};
|
||||
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ use crate::noqa::{add_noqa, rule_is_ignored};
|
|||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::rules::pycodestyle;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Indexer, Locator, Stylist};
|
||||
use crate::{directives, fs};
|
||||
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
|
||||
|
||||
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const CARGO_PKG_REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");
|
||||
|
|
|
@ -3,10 +3,10 @@ use std::cmp::Ordering;
|
|||
pub use rustpython_parser::ast::Location;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::source_code::Locator;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Message {
|
||||
|
|
|
@ -11,11 +11,11 @@ use regex::Regex;
|
|||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::codes::NoqaCode;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::rule_redirects::get_redirect_target;
|
||||
use crate::source_code::{LineEnding, Locator};
|
||||
use ruff_python_ast::source_code::{LineEnding, Locator};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
static NOQA_LINE_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||
Regex::new(
|
||||
|
@ -332,12 +332,12 @@ mod tests {
|
|||
use nohash_hasher::IntMap;
|
||||
use rustpython_parser::ast::Location;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::noqa::{add_noqa_inner, NOQA_LINE_REGEX};
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::pycodestyle::rules::AmbiguousVariableName;
|
||||
use crate::rules::pyflakes;
|
||||
use crate::source_code::LineEnding;
|
||||
use ruff_python_ast::source_code::LineEnding;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
#[test]
|
||||
fn regex() {
|
||||
|
|
|
@ -5,11 +5,11 @@ use rustpython_parser::ast::Location;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{AsRefStr, EnumIter};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::codes::{self, RuleCodePrefix};
|
||||
use crate::fix::Fix;
|
||||
use crate::rules;
|
||||
use crate::violation::Violation;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
ruff_macros::register_rules!(
|
||||
// pycodestyle errors
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::Location;
|
||||
|
||||
use super::detection::comment_contains_code;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::Locator;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::detection::comment_contains_code;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for commented-out Python code.
|
||||
///
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use num_bigint::BigInt;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Cmpop, Constant, Expr, ExprKind, Located};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -2,9 +2,10 @@ use anyhow::{bail, Result};
|
|||
use rustpython_parser::ast::Stmt;
|
||||
use rustpython_parser::{lexer, Mode, Tok};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::fix::Fix;
|
||||
use crate::source_code::Locator;
|
||||
|
||||
/// ANN204
|
||||
pub fn add_return_none_annotation(locator: &Locator, stmt: &Stmt) -> Result<Fix> {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use rustpython_parser::ast::{Arguments, Expr, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::cast;
|
||||
use crate::ast::visibility;
|
||||
use ruff_python_ast::cast;
|
||||
use ruff_python_ast::visibility;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Stmt};
|
||||
|
||||
use super::fixes;
|
||||
use super::helpers::match_function_def;
|
||||
use crate::ast::helpers::ReturnStatementVisitor;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visibility;
|
||||
use crate::ast::visibility::Visibility;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::ast::{cast, helpers};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::ReturnStatementVisitor;
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_ast::visibility;
|
||||
use ruff_python_ast::visibility::Visibility;
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
use ruff_python_ast::{cast, helpers};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
|
||||
use super::fixes;
|
||||
use super::helpers::match_function_def;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks that function arguments have type annotations.
|
||||
///
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
//! Settings for the `flake-annotations` plugin.
|
||||
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use ruff_macros::CacheKey;
|
||||
use ruff_macros::ConfigurationOptions;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, Default, Serialize, Deserialize, ConfigurationOptions, JsonSchema,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::Stmt;
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use num_traits::ToPrimitive;
|
||||
use once_cell::sync::Lazy;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword, Operator};
|
||||
|
||||
use crate::ast::helpers::{compose_call_path, SimpleCallArgs};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::{compose_call_path, SimpleCallArgs};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::{Arg, Arguments, Expr};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::Keyword;
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
|
||||
#[violation]
|
||||
pub struct HardcodedPasswordFuncArg {
|
||||
pub string: String,
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
|
||||
#[violation]
|
||||
pub struct HardcodedPasswordString {
|
||||
pub string: String,
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Operator};
|
||||
|
||||
use super::super::helpers::string_literal;
|
||||
use crate::ast::helpers::{any_over_expr, unparse_expr};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::{any_over_expr, unparse_expr};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::super::helpers::string_literal;
|
||||
|
||||
static SQL_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||
Regex::new(r"(?i)(select\s.*from\s|delete\s+from\s|insert\s+into\s.*values\s|update\s.*set\s)")
|
||||
.unwrap()
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::Expr;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use super::super::helpers::string_literal;
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::super::helpers::string_literal;
|
||||
|
||||
#[violation]
|
||||
pub struct HashlibInsecureHashFunction {
|
||||
pub string: String,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::{unparse_constant, SimpleCallArgs};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::{unparse_constant, SimpleCallArgs};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use num_traits::{One, Zero};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::{Excepthandler, Expr, Stmt, StmtKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_bandit::helpers::is_untyped_exception;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::{Excepthandler, Expr, Stmt, StmtKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_bandit::helpers::is_untyped_exception;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::SimpleCallArgs;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
//! Settings for the `flake8-bandit` plugin.
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
|
||||
fn default_tmp_dirs() -> Vec<String> {
|
||||
["/tmp", "/var/tmp", "/dev/shm"]
|
||||
.map(std::string::ToString::to_string)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::ast::helpers::{find_keyword, is_const_true};
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers;
|
||||
use ruff_python_ast::helpers::{find_keyword, is_const_true};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::collect_call_path;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::helpers::collect_call_path;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visibility::{is_abstract, is_overload};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_ast::visibility::{is_abstract, is_overload};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::unparse_stmt;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::unparse_stmt;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{ExprKind, Stmt, Withitem};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::{Range, ScopeKind};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::{Range, ScopeKind};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustpython_parser::ast::{
|
||||
Excepthandler, ExcepthandlerKind, Expr, ExprContext, ExprKind, Location,
|
||||
};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::{CallPath, Range};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers;
|
||||
use ruff_python_ast::helpers::unparse_expr;
|
||||
use ruff_python_ast::types::{CallPath, Range};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::Excepthandler;
|
||||
use rustpython_parser::ast::{ExcepthandlerKind, ExprKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use rustpython_parser::ast::{ExcepthandlerKind, ExprKind};
|
||||
|
||||
#[violation]
|
||||
pub struct ExceptWithEmptyTuple;
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind};
|
||||
|
||||
use super::mutable_argument_default::is_mutable_func;
|
||||
use crate::ast::helpers::{compose_call_path, to_call_path};
|
||||
use crate::ast::types::{CallPath, Range};
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::{compose_call_path, to_call_path};
|
||||
use ruff_python_ast::types::{CallPath, Range};
|
||||
use ruff_python_ast::visitor;
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::mutable_argument_default::is_mutable_func;
|
||||
|
||||
#[violation]
|
||||
pub struct FunctionCallArgumentDefault {
|
||||
pub name: Option<String>,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_parser::ast::{Comprehension, Expr, ExprContext, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::collect_arg_names;
|
||||
use crate::ast::types::{Node, Range};
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::collect_arg_names;
|
||||
use ruff_python_ast::types::{Node, Range};
|
||||
use ruff_python_ast::visitor;
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::unparse_expr;
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python_stdlib::keyword::KWLIST;
|
||||
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_ast::visitor;
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -34,6 +34,9 @@ pub use star_arg_unpacking_after_keyword_arg::{
|
|||
};
|
||||
pub use strip_with_multi_characters::{strip_with_multi_characters, StripWithMultiCharacters};
|
||||
pub use unary_prefix_increment::{unary_prefix_increment, UnaryPrefixIncrement};
|
||||
pub use unintentional_type_annotation::{
|
||||
unintentional_type_annotation, UnintentionalTypeAnnotation,
|
||||
};
|
||||
pub use unreliable_callable_check::{unreliable_callable_check, UnreliableCallableCheck};
|
||||
pub use unused_loop_control_variable::{unused_loop_control_variable, UnusedLoopControlVariable};
|
||||
pub use useless_comparison::{useless_comparison, UselessComparison};
|
||||
|
@ -41,10 +44,6 @@ pub use useless_contextlib_suppress::{useless_contextlib_suppress, UselessContex
|
|||
pub use useless_expression::{useless_expression, UselessExpression};
|
||||
pub use zip_without_explicit_strict::{zip_without_explicit_strict, ZipWithoutExplicitStrict};
|
||||
|
||||
pub use unintentional_type_annotation::{
|
||||
unintentional_type_annotation, UnintentionalTypeAnnotation,
|
||||
};
|
||||
|
||||
mod abstract_base_class;
|
||||
mod assert_false;
|
||||
mod assert_raises_exception;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind, Operator};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use rustpython_parser::ast::{ExprKind, Stmt};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::RaiseStatementVisitor;
|
||||
use ruff_python_ast::visitor;
|
||||
use ruff_python_stdlib::str::is_lower;
|
||||
|
||||
use crate::ast::helpers::RaiseStatementVisitor;
|
||||
use crate::ast::visitor;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Excepthandler, ExcepthandlerKind, ExprKind};
|
||||
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::unparse_expr;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::helpers::unparse_stmt;
|
||||
use ruff_python_ast::source_code::Stylist;
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python_stdlib::keyword::KWLIST;
|
||||
|
||||
use crate::ast::helpers::unparse_stmt;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::source_code::Stylist;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
#[violation]
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
//! by the unpacked sequence, and this change of ordering can surprise and
|
||||
//! mislead readers.
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
//! n += 1
|
||||
//! ```
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Unaryop};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::{Expr, ExprKind, Stmt};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -18,14 +18,15 @@
|
|||
//! method()
|
||||
//! ```
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Stmt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::ast::types::{Range, RefEquality};
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::ast::{helpers, visitor};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::{Range, RefEquality};
|
||||
use ruff_python_ast::visitor::Visitor;
|
||||
use ruff_python_ast::{helpers, visitor};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::Expr;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
//! Settings for the `flake8-bugbear` plugin.
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, Default, Serialize, Deserialize, ConfigurationOptions, JsonSchema,
|
||||
)]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use rustpython_parser::ast::Located;
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
use ruff_python_stdlib::builtins::BUILTINS;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violation::Violation;
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
//! Settings for the `flake8-builtins` plugin.
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use ruff_macros::{CacheKey, ConfigurationOptions};
|
||||
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, Default, Serialize, Deserialize, ConfigurationOptions, JsonSchema,
|
||||
)]
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::lexer::{LexResult, Spanned};
|
||||
use rustpython_parser::Tok;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::Locator;
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
|
||||
/// Simplified token type.
|
||||
|
|
|
@ -7,10 +7,11 @@ use libcst_native::{
|
|||
RightParen, RightSquareBracket, Set, SetComp, SimpleString, SimpleWhitespace, Tuple,
|
||||
};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_python_ast::source_code::{Locator, Stylist};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::cst::matchers::{match_expr, match_module};
|
||||
use crate::fix::Fix;
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
|
||||
fn match_call<'a, 'b>(expr: &'a mut Expr<'b>) -> Result<&'a mut Call<'b>> {
|
||||
if let Expression::Call(call) = &mut expr.value {
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
mod helpers;
|
||||
mod unnecessary_call_around_sorted;
|
||||
mod unnecessary_collection_call;
|
||||
mod unnecessary_comprehension;
|
||||
mod unnecessary_double_cast_or_process;
|
||||
mod unnecessary_generator_dict;
|
||||
mod unnecessary_generator_list;
|
||||
mod unnecessary_generator_set;
|
||||
mod unnecessary_list_call;
|
||||
mod unnecessary_list_comprehension_dict;
|
||||
mod unnecessary_list_comprehension_set;
|
||||
mod unnecessary_literal_dict;
|
||||
mod unnecessary_literal_set;
|
||||
mod unnecessary_literal_within_list_call;
|
||||
mod unnecessary_literal_within_tuple_call;
|
||||
mod unnecessary_map;
|
||||
mod unnecessary_subscript_reversal;
|
||||
|
||||
pub use unnecessary_call_around_sorted::{
|
||||
unnecessary_call_around_sorted, UnnecessaryCallAroundSorted,
|
||||
};
|
||||
|
@ -46,3 +28,21 @@ pub use unnecessary_map::{unnecessary_map, UnnecessaryMap};
|
|||
pub use unnecessary_subscript_reversal::{
|
||||
unnecessary_subscript_reversal, UnnecessarySubscriptReversal,
|
||||
};
|
||||
|
||||
mod helpers;
|
||||
mod unnecessary_call_around_sorted;
|
||||
mod unnecessary_collection_call;
|
||||
mod unnecessary_comprehension;
|
||||
mod unnecessary_double_cast_or_process;
|
||||
mod unnecessary_generator_dict;
|
||||
mod unnecessary_generator_list;
|
||||
mod unnecessary_generator_set;
|
||||
mod unnecessary_list_call;
|
||||
mod unnecessary_list_comprehension_dict;
|
||||
mod unnecessary_list_comprehension_set;
|
||||
mod unnecessary_literal_dict;
|
||||
mod unnecessary_literal_set;
|
||||
mod unnecessary_literal_within_list_call;
|
||||
mod unnecessary_literal_within_tuple_call;
|
||||
mod unnecessary_map;
|
||||
mod unnecessary_subscript_reversal;
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for unnecessary `list` or `reversed` calls around `sorted`
|
||||
/// calls.
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::rules::flake8_comprehensions::settings::Settings;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryCollectionCall {
|
||||
pub obj_type: String,
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Comprehension, Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryComprehension {
|
||||
pub obj_type: String,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for unnecessary generators that can be rewritten as `dict`
|
||||
/// comprehensions.
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for unnecessary generators that can be rewritten as `list`
|
||||
/// comprehensions.
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for unnecessary generators that can be rewritten as `set`
|
||||
/// comprehensions.
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryListCall;
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryListComprehensionDict;
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryListComprehensionSet;
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryLiteralDict {
|
||||
pub obj_type: String,
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryLiteralSet {
|
||||
pub obj_type: String,
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryLiteralWithinListCall {
|
||||
pub literal: String,
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use log::error;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessaryLiteralWithinTupleCall {
|
||||
pub literal: String,
|
||||
|
|
|
@ -2,8 +2,8 @@ use log::error;
|
|||
use rustpython_parser::ast::{Expr, ExprKind};
|
||||
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
use num_bigint::BigInt;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use rustpython_parser::ast::{Constant, Expr, ExprKind, Unaryop};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::types::Range;
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use super::helpers;
|
||||
|
||||
#[violation]
|
||||
pub struct UnnecessarySubscriptReversal {
|
||||
pub func: String,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue