mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
Reorder imports (#2638)
This commit is contained in:
parent
0355ba571e
commit
67e9ff7cc8
233 changed files with 626 additions and 593 deletions
|
@ -667,8 +667,8 @@ pub fn to_call_path(target: &str) -> CallPath {
|
|||
|
||||
/// Create a module path from a (package, path) pair.
|
||||
///
|
||||
/// For example, if the package is `foo/bar` and the path is `foo/bar/baz.py`, the call path is
|
||||
/// `["baz"]`.
|
||||
/// For example, if the package is `foo/bar` and the path is `foo/bar/baz.py`,
|
||||
/// the call path is `["baz"]`.
|
||||
pub fn to_module_path(package: &Path, path: &Path) -> Option<Vec<String>> {
|
||||
path.strip_prefix(package.parent()?)
|
||||
.ok()?
|
||||
|
|
|
@ -89,8 +89,9 @@ pub struct Scope<'a> {
|
|||
pub uses_locals: bool,
|
||||
/// A map from bound name to binding index, for live bindings.
|
||||
pub bindings: FxHashMap<&'a str, usize>,
|
||||
/// A map from bound name to binding index, for bindings that were created in the scope but
|
||||
/// rebound (and thus overridden) later on in the same scope.
|
||||
/// A map from bound name to binding index, for bindings that were created
|
||||
/// in the scope but rebound (and thus overridden) later on in the same
|
||||
/// scope.
|
||||
pub rebounds: FxHashMap<&'a str, Vec<usize>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use ruff_python::typing::{PEP_585_BUILTINS_ELIGIBLE, PEP_593_SUBSCRIPTS, SUBSCRIPTS};
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::CallPath;
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ use std::path::Path;
|
|||
use itertools::Itertools;
|
||||
use log::error;
|
||||
use nohash_hasher::IntMap;
|
||||
use ruff_python::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||
use ruff_python::typing::TYPING_EXTENSIONS;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustpython_ast::{Comprehension, Located, Location};
|
||||
use rustpython_common::cformat::{CFormatError, CFormatErrorType};
|
||||
|
@ -16,9 +18,6 @@ use rustpython_parser::ast::{
|
|||
use rustpython_parser::parser;
|
||||
use smallvec::smallvec;
|
||||
|
||||
use ruff_python::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||
use ruff_python::typing::TYPING_EXTENSIONS;
|
||||
|
||||
use crate::ast::helpers::{
|
||||
binding_range, collect_call_path, extract_handler_names, from_relative_import, to_module_path,
|
||||
};
|
||||
|
@ -3955,8 +3954,8 @@ impl<'a> Checker<'a> {
|
|||
// Avoid overriding builtins.
|
||||
binding
|
||||
} else if matches!(self.bindings[*index].kind, BindingKind::Global) {
|
||||
// If the original binding was a global, and the new binding conflicts within the
|
||||
// current scope, then the new binding is also a global.
|
||||
// If the original binding was a global, and the new binding conflicts within
|
||||
// the current scope, then the new binding is also a global.
|
||||
Binding {
|
||||
runtime_usage: self.bindings[*index].runtime_usage,
|
||||
synthetic_usage: self.bindings[*index].synthetic_usage,
|
||||
|
@ -3965,8 +3964,8 @@ impl<'a> Checker<'a> {
|
|||
..binding
|
||||
}
|
||||
} else if matches!(self.bindings[*index].kind, BindingKind::Nonlocal) {
|
||||
// If the original binding was a nonlocal, and the new binding conflicts within the
|
||||
// current scope, then the new binding is also a nonlocal.
|
||||
// If the original binding was a nonlocal, and the new binding conflicts within
|
||||
// the current scope, then the new binding is also a nonlocal.
|
||||
Binding {
|
||||
runtime_usage: self.bindings[*index].runtime_usage,
|
||||
synthetic_usage: self.bindings[*index].synthetic_usage,
|
||||
|
|
|
@ -27,8 +27,9 @@ use crate::{directives, fs, rustpython_helpers};
|
|||
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const CARGO_PKG_REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");
|
||||
|
||||
/// A [`Result`]-like type that returns both data and an error. Used to return diagnostics even in
|
||||
/// the face of parse errors, since many diagnostics can be generated without a full AST.
|
||||
/// A [`Result`]-like type that returns both data and an error. Used to return
|
||||
/// diagnostics even in the face of parse errors, since many diagnostics can be
|
||||
/// generated without a full AST.
|
||||
pub struct LinterResult<T> {
|
||||
pub data: T,
|
||||
pub error: Option<ParseError>,
|
||||
|
@ -270,7 +271,8 @@ pub fn add_noqa_to_path(path: &Path, settings: &Settings) -> Result<usize> {
|
|||
)
|
||||
}
|
||||
|
||||
/// Generate a [`Message`] for each [`Diagnostic`] triggered by the given source code.
|
||||
/// Generate a [`Message`] for each [`Diagnostic`] triggered by the given source
|
||||
/// code.
|
||||
pub fn lint_only(
|
||||
contents: &str,
|
||||
path: &Path,
|
||||
|
|
|
@ -50,7 +50,8 @@ macro_rules! notify_user {
|
|||
pub enum LogLevel {
|
||||
/// No output ([`log::LevelFilter::Off`]).
|
||||
Silent,
|
||||
/// Only show lint violations, with no decorative output ([`log::LevelFilter::Off`]).
|
||||
/// Only show lint violations, with no decorative output
|
||||
/// ([`log::LevelFilter::Off`]).
|
||||
Quiet,
|
||||
/// All user-facing output ([`log::LevelFilter::Info`]).
|
||||
#[default]
|
||||
|
|
|
@ -119,7 +119,8 @@ pub fn detect_package_roots<'a>(
|
|||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::{packaging::detect_package_root, test::test_resource_path};
|
||||
use crate::packaging::detect_package_root;
|
||||
use crate::test::test_resource_path;
|
||||
|
||||
#[test]
|
||||
fn package_detection() {
|
||||
|
|
|
@ -587,15 +587,16 @@ mod tests {
|
|||
&Relativity::Parent,
|
||||
&NoOpProcessor,
|
||||
)?);
|
||||
// src/app.py should not be excluded even if it lives in a hierarchy that should be
|
||||
// excluded by virtue of the pyproject.toml having `resources/*` in it.
|
||||
// src/app.py should not be excluded even if it lives in a hierarchy that should
|
||||
// be excluded by virtue of the pyproject.toml having `resources/*` in
|
||||
// it.
|
||||
assert!(!is_file_excluded(
|
||||
&package_root.join("src/app.py"),
|
||||
&resolver,
|
||||
&ppd,
|
||||
));
|
||||
// However, resources/ignored.py should be ignored, since that `resources` is beneath
|
||||
// the package root.
|
||||
// However, resources/ignored.py should be ignored, since that `resources` is
|
||||
// beneath the package root.
|
||||
assert!(is_file_excluded(
|
||||
&package_root.join("resources/ignored.py"),
|
||||
&resolver,
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use num_bigint::BigInt;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Cmpop, Constant, Expr, ExprKind, Located};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
|
||||
use crate::define_violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct SysVersionSlice3Referenced;
|
||||
);
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Stmt};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
use super::fixes;
|
||||
use super::helpers::match_function_def;
|
||||
use crate::ast::helpers::ReturnStatementVisitor;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::ast::{cast, helpers};
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
use crate::visibility;
|
||||
use crate::visibility::Visibility;
|
||||
|
||||
use super::fixes;
|
||||
use super::helpers::match_function_def;
|
||||
use crate::{define_violation, visibility};
|
||||
|
||||
define_violation!(
|
||||
pub struct MissingTypeFunctionArgument {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Located, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct AssertUsed;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use num_traits::ToPrimitive;
|
||||
use once_cell::sync::Lazy;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
@ -9,7 +7,9 @@ use rustpython_ast::{Constant, Expr, ExprKind, Keyword, Operator};
|
|||
use crate::ast::helpers::{compose_call_path, SimpleCallArgs};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct BadFilePermissions {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct ExecUsed;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use crate::define_violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct HardcodedBindAllInterfaces;
|
||||
);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{ArgData, Arguments, Expr, Located};
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct HardcodedPasswordDefault {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Keyword;
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct HardcodedPasswordFuncArg {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct HardcodedPasswordString {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Expr;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct HardcodedTempFile {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
|
@ -7,7 +5,9 @@ use super::super::helpers::string_literal;
|
|||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct HashlibInsecureHashFunction {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
use rustpython_parser::ast::Constant;
|
||||
|
@ -7,7 +5,9 @@ use rustpython_parser::ast::Constant;
|
|||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct Jinja2AutoescapeFalse {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
use rustpython_parser::ast::Constant;
|
||||
|
@ -7,7 +5,9 @@ use rustpython_parser::ast::Constant;
|
|||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct RequestWithNoCertValidation {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
use rustpython_parser::ast::Constant;
|
||||
|
@ -7,7 +5,9 @@ use rustpython_parser::ast::Constant;
|
|||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct RequestWithoutTimeout {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use num_traits::{One, Zero};
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
@ -8,7 +6,9 @@ use rustpython_parser::ast::Constant;
|
|||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct SnmpInsecureVersion;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct SnmpWeakCryptography;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
|
|
|
@ -39,8 +39,9 @@ pub struct Options {
|
|||
value_type = "bool",
|
||||
example = "check-typed-exception = true"
|
||||
)]
|
||||
/// Whether to disallow `try`-`except`-`pass` (`S110`) for specific exception types. By default,
|
||||
/// `try`-`except`-`pass` is only disallowed for `Exception` and `BaseException`.
|
||||
/// Whether to disallow `try`-`except`-`pass` (`S110`) for specific
|
||||
/// exception types. By default, `try`-`except`-`pass` is only
|
||||
/// disallowed for `Exception` and `BaseException`.
|
||||
pub check_typed_exception: Option<bool>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::ast::helpers::{find_keyword, is_const_true};
|
||||
use crate::ast::types::Range;
|
||||
|
@ -5,8 +8,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct BlindExcept {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
use crate::visibility::{is_abstract, is_overload};
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct AbstractBaseClassWithoutAbstractMethod {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::unparse_stmt;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,8 +8,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct DoNotAssertFalse;
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
//! typo. Either assert for a more specific exception (builtin or
|
||||
//! custom), use `assertRaisesRegex`, or use the context manager form of
|
||||
//! `assertRaises`.
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{ExprKind, Stmt, Withitem};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{ExprKind, Stmt, Withitem};
|
||||
|
||||
define_violation!(
|
||||
pub struct NoAssertRaisesException;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct AssignmentToOsEnviron;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::{Range, ScopeKind};
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct CachedInstanceMethod;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct CannotRaiseLiteral;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustpython_ast::{Excepthandler, ExcepthandlerKind, Expr, ExprContext, ExprKind, Location};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::{CallPath, Range};
|
||||
|
@ -6,10 +11,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustpython_ast::{Excepthandler, ExcepthandlerKind, Expr, ExprContext, ExprKind, Location};
|
||||
|
||||
define_violation!(
|
||||
pub struct DuplicateTryBlockException {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct FStringDocstring;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_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};
|
||||
|
@ -7,8 +10,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Arguments, Constant, Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct FunctionCallArgumentDefault {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Comprehension, Expr, ExprContext, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::collect_arg_names;
|
||||
use crate::ast::types::{Node, Range};
|
||||
use crate::ast::visitor;
|
||||
|
@ -6,9 +10,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Comprehension, Expr, ExprContext, ExprKind, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct FunctionUsesLoopVariable {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python::keyword::KWLIST;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location};
|
||||
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,10 +10,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python::keyword::KWLIST;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location};
|
||||
|
||||
define_violation!(
|
||||
pub struct GetAttrWithConstant;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct JumpStatementInFinally {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
|
@ -5,9 +9,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct LoopVariableOverridesIterator {
|
||||
|
|
|
@ -27,7 +27,6 @@ pub use raise_without_from_inside_except::{
|
|||
pub use redundant_tuple_in_exception_handler::{
|
||||
redundant_tuple_in_exception_handler, RedundantTupleInExceptionHandler,
|
||||
};
|
||||
|
||||
pub use setattr_with_constant::{setattr_with_constant, SetAttrWithConstant};
|
||||
pub use star_arg_unpacking_after_keyword_arg::{
|
||||
star_arg_unpacking_after_keyword_arg, StarArgUnpackingAfterKeywordArg,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Arguments, Constant, Expr, ExprKind, Operator};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Arguments, Constant, Expr, ExprKind, Operator};
|
||||
|
||||
define_violation!(
|
||||
pub struct MutableArgumentDefault;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::string::is_lower;
|
||||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::string::is_lower;
|
||||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct RaiseWithoutFromInsideExcept;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Excepthandler, ExcepthandlerKind, ExprKind};
|
||||
|
||||
use crate::ast::helpers::unparse_expr;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,8 +8,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Excepthandler, ExcepthandlerKind, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct RedundantTupleInExceptionHandler {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python::keyword::KWLIST;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::unparse_stmt;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -6,10 +11,6 @@ use crate::fix::Fix;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::source_code::Stylist;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::identifiers::{is_identifier, is_mangled_private};
|
||||
use ruff_python::keyword::KWLIST;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct SetAttrWithConstant;
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
//! by the unpacked sequence, and this change of ordering can surprise and
|
||||
//! mislead readers.
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct StarArgUnpackingAfterKeywordArg;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct StripWithMultiCharacters;
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
//! n += 1
|
||||
//! ```
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Unaryop};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Unaryop};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnaryPrefixIncrement;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnreliableCallableCheck;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
//! method()
|
||||
//! ```
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_ast::{Expr, ExprKind, Stmt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::iter;
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashMap;
|
||||
use rustpython_ast::{Expr, ExprKind, Stmt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::ast::types::{BindingKind, Range, RefEquality};
|
||||
use crate::ast::visitor::Visitor;
|
||||
|
@ -44,11 +44,13 @@ define_violation!(
|
|||
pub struct UnusedLoopControlVariable {
|
||||
/// The name of the loop control variable.
|
||||
pub name: String,
|
||||
/// The name to which the variable should be renamed, if it can be safely renamed.
|
||||
/// The name to which the variable should be renamed, if it can be
|
||||
/// safely renamed.
|
||||
pub rename: Option<String>,
|
||||
/// Whether the variable is certain to be unused in the loop body, or merely suspect.
|
||||
/// A variable _may_ be used, but undetectably so, if the loop incorporates
|
||||
/// by magic control flow (e.g., `locals()`).
|
||||
/// Whether the variable is certain to be unused in the loop body, or
|
||||
/// merely suspect. A variable _may_ be used, but undetectably
|
||||
/// so, if the loop incorporates by magic control flow (e.g.,
|
||||
/// `locals()`).
|
||||
pub certainty: Certainty,
|
||||
}
|
||||
);
|
||||
|
@ -147,8 +149,9 @@ pub fn unused_loop_control_variable(
|
|||
Certainty::Certain
|
||||
};
|
||||
|
||||
// Attempt to rename the variable by prepending an underscore, but avoid applying the fix
|
||||
// if doing so wouldn't actually cause us to ignore the violation in the next pass.
|
||||
// Attempt to rename the variable by prepending an underscore, but avoid
|
||||
// applying the fix if doing so wouldn't actually cause us to ignore the
|
||||
// violation in the next pass.
|
||||
let rename = format!("_{name}");
|
||||
let rename = if checker
|
||||
.settings
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UselessComparison;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Expr;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Expr;
|
||||
|
||||
define_violation!(
|
||||
pub struct UselessContextlibSuppress;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, ExprKind, Stmt, StmtKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UselessExpression;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct ZipWithoutExplicitStrict;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::builtins::BUILTINS;
|
||||
use rustpython_ast::Located;
|
||||
|
||||
use super::types::ShadowingType;
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::builtins::BUILTINS;
|
||||
use rustpython_ast::Located;
|
||||
|
||||
define_violation!(
|
||||
pub struct BuiltinVariableShadowing {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryCallAroundSorted {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryCollectionCall {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Comprehension, Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Comprehension, Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryComprehension {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryDoubleCastOrProcess {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryGeneratorDict;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryGeneratorList;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryGeneratorSet;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryListCall;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryListComprehensionDict;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryListComprehensionSet;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryLiteralDict {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryLiteralSet {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryLiteralWithinListCall {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,9 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_comprehensions::fixes;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryLiteralWithinTupleCall {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryMap {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use num_bigint::BigInt;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Unaryop};
|
||||
|
||||
use super::helpers;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
|
||||
use crate::violation::Violation;
|
||||
use num_bigint::BigInt;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Unaryop};
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessarySubscriptReversal {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use crate::ast::helpers::{has_non_none_keyword, is_const_none};
|
||||
use crate::ast::types::Range;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Stmt};
|
||||
|
||||
use super::types::DebuggerUsingType;
|
||||
|
@ -8,8 +9,6 @@ use crate::define_violation;
|
|||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
// flake8-debugger
|
||||
|
||||
define_violation!(
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
|
||||
use crate::define_violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct RawStringInException;
|
||||
);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Operator};
|
||||
use rustpython_parser::lexer::{LexResult, Tok};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use log::error;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Boolop, Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use ruff_python::identifiers::is_identifier;
|
||||
use ruff_python::keyword::KWLIST;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Boolop, Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::comparable::ComparableExpr;
|
||||
use crate::ast::helpers::{match_trailing_comment, unparse_expr};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use log::error;
|
||||
use rustpython_ast::{Expr, Keyword, Stmt, StmtKind};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::helpers::is_const_none;
|
||||
use crate::ast::types::Range;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{
|
||||
Boolop, Excepthandler, ExcepthandlerKind, Expr, ExprKind, Keyword, Stmt, StmtKind, Unaryop,
|
||||
};
|
||||
|
@ -13,7 +14,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct CompositeAssertion;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, Keyword};
|
||||
|
||||
use super::helpers::{is_empty_or_null_string, is_pytest_fail};
|
||||
|
@ -7,7 +8,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct FailWithoutMessage;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Stmt;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct IncorrectPytestImport;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Location};
|
||||
|
||||
use super::helpers::{get_mark_decorators, get_mark_name};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -5,8 +8,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Location};
|
||||
|
||||
define_violation!(
|
||||
pub struct IncorrectMarkParenthesesStyle {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind};
|
||||
|
||||
use super::super::types;
|
||||
use super::helpers::{is_pytest_parametrize, split_names};
|
||||
use crate::ast::helpers::{create_expr, unparse_expr};
|
||||
|
@ -8,8 +11,6 @@ use crate::fix::Fix;
|
|||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::source_code::Generator;
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct ParametrizeNamesWrongType {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||
|
||||
|
@ -8,7 +9,6 @@ use crate::ast::visitor::Visitor;
|
|||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct PatchWithLambda;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind, Keyword, Stmt, StmtKind, Withitem};
|
||||
|
||||
use super::helpers::is_empty_or_null_string;
|
||||
|
@ -7,7 +8,6 @@ use crate::checkers::ast::Checker;
|
|||
use crate::define_violation;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct RaisesWithMultipleStatements;
|
||||
|
|
|
@ -50,8 +50,8 @@ pub struct Options {
|
|||
///
|
||||
/// * `csv` — a comma-separated list, e.g.
|
||||
/// `@pytest.mark.parametrize('name1,name2', ...)`
|
||||
/// * `tuple` (default) — e.g.
|
||||
/// `@pytest.mark.parametrize(('name1', 'name2'), ...)`
|
||||
/// * `tuple` (default) — e.g. `@pytest.mark.parametrize(('name1', 'name2'),
|
||||
/// ...)`
|
||||
/// * `list` — e.g. `@pytest.mark.parametrize(['name1', 'name2'], ...)`
|
||||
pub parametrize_names_type: Option<types::ParametrizeNameType>,
|
||||
#[option(
|
||||
|
@ -73,10 +73,10 @@ pub struct Options {
|
|||
/// Expected type for each row of values in `@pytest.mark.parametrize` in
|
||||
/// case of multiple parameters. The following values are supported:
|
||||
///
|
||||
/// * `tuple` (default) — e.g.
|
||||
/// `@pytest.mark.parametrize(('name1', 'name2'), [(1, 2), (3, 4)])`
|
||||
/// * `list` — e.g.
|
||||
/// `@pytest.mark.parametrize(('name1', 'name2'), [[1, 2], [3, 4]])`
|
||||
/// * `tuple` (default) — e.g. `@pytest.mark.parametrize(('name1', 'name2'),
|
||||
/// [(1, 2), (3, 4)])`
|
||||
/// * `list` — e.g. `@pytest.mark.parametrize(('name1', 'name2'), [[1, 2],
|
||||
/// [3, 4]])`
|
||||
pub parametrize_values_row_type: Option<types::ParametrizeValuesRowType>,
|
||||
#[option(
|
||||
default = r#"["BaseException", "Exception", "ValueError", "OSError", "IOError", "EnvironmentError", "socket.error"]"#,
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Location;
|
||||
use rustpython_parser::lexer::{LexResult, Tok};
|
||||
|
||||
use super::settings::Quote;
|
||||
use crate::ast::types::Range;
|
||||
use crate::define_violation;
|
||||
|
@ -8,10 +12,6 @@ use crate::settings::{flags, Settings};
|
|||
use crate::source_code::Locator;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::Location;
|
||||
use rustpython_parser::lexer::{LexResult, Tok};
|
||||
|
||||
define_violation!(
|
||||
pub struct BadQuotesInlineString {
|
||||
pub quote: Quote,
|
||||
|
@ -231,8 +231,8 @@ fn strings(
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Return `true` if any of the strings are inline strings that contain the quote character in
|
||||
// the body.
|
||||
// Return `true` if any of the strings are inline strings that contain the quote
|
||||
// character in the body.
|
||||
let relax_quote = trivia.iter().any(|trivia| {
|
||||
if trivia.is_multiline {
|
||||
return false;
|
||||
|
@ -393,15 +393,15 @@ pub fn from_tokens(
|
|||
) -> Vec<Diagnostic> {
|
||||
let mut diagnostics = vec![];
|
||||
|
||||
// Keep track of sequences of strings, which represent implicit string concatenation, and
|
||||
// should thus be handled as a single unit.
|
||||
// Keep track of sequences of strings, which represent implicit string
|
||||
// concatenation, and should thus be handled as a single unit.
|
||||
let mut sequence = vec![];
|
||||
let mut state_machine = StateMachine::default();
|
||||
for &(start, ref tok, end) in lxr.iter().flatten() {
|
||||
let is_docstring = state_machine.consume(tok);
|
||||
|
||||
// If this is a docstring, consume the existing sequence, then consume the docstring, then
|
||||
// move on.
|
||||
// If this is a docstring, consume the existing sequence, then consume the
|
||||
// docstring, then move on.
|
||||
if is_docstring {
|
||||
if !sequence.is_empty() {
|
||||
diagnostics.extend(strings(locator, &sequence, settings, autofix));
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::helpers::match_parens;
|
||||
use crate::checkers::ast::Checker;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use itertools::Itertools;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Location, Stmt, StmtKind};
|
||||
|
||||
use super::branch::Branch;
|
||||
|
@ -13,7 +14,6 @@ use crate::define_violation;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::violation::{AlwaysAutofixableViolation, Violation};
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
define_violation!(
|
||||
pub struct UnnecessaryReturnNone;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct PrivateMemberAccess {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::iter;
|
||||
|
||||
use itertools::Either::{Left, Right};
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Boolop, Cmpop, Constant, Expr, ExprContext, ExprKind, Unaryop};
|
||||
|
||||
use crate::ast::helpers::{contains_effect, create_expr, has_comments, unparse_expr};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct DuplicateIsinstanceCall {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use crate::ast::helpers::{create_expr, unparse_expr};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct UseCapitalEnvironmentVariables {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{
|
||||
Comprehension, Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind, Unaryop,
|
||||
|
@ -8,9 +6,11 @@ use rustpython_ast::{
|
|||
use crate::ast::helpers::{create_expr, create_stmt, unparse_stmt};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::source_code::Stylist;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct ConvertLoopToAny {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::violation::{AlwaysAutofixableViolation, Availability, Violation};
|
||||
use crate::{define_violation, AutofixKind};
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Cmpop, Constant, Expr, ExprContext, ExprKind, Stmt, StmtKind};
|
||||
|
@ -14,6 +12,8 @@ use crate::checkers::ast::Checker;
|
|||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::rules::flake8_simplify::rules::fix_if;
|
||||
use crate::violation::{AlwaysAutofixableViolation, Availability, Violation};
|
||||
use crate::{define_violation, AutofixKind};
|
||||
|
||||
define_violation!(
|
||||
pub struct NestedIfStatements;
|
||||
|
@ -240,7 +240,8 @@ pub fn return_bool_condition_directly(checker: &mut Checker, stmt: &Stmt) {
|
|||
return;
|
||||
};
|
||||
|
||||
// If the branches have the same condition, abort (although the code could be simplified).
|
||||
// If the branches have the same condition, abort (although the code could be
|
||||
// simplified).
|
||||
if if_return == else_return {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Unaryop};
|
||||
|
||||
use crate::ast::helpers::{create_expr, unparse_expr};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct IfExprWithTrueFalse {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Cmpop, Expr, ExprKind, Stmt, StmtKind, Unaryop};
|
||||
|
||||
use crate::ast::helpers::{create_expr, unparse_expr};
|
||||
use crate::ast::types::{Range, ScopeKind};
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct NegateEqualOp {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use log::error;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Located, Stmt, StmtKind, Withitem};
|
||||
|
@ -8,7 +6,9 @@ use super::fix_with;
|
|||
use crate::ast::helpers::{first_colon_range, has_comments_in};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct MultipleWithStatements;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Cmpop, Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::AlwaysAutofixableViolation;
|
||||
|
||||
define_violation!(
|
||||
pub struct KeyInDict {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
use rustpython_parser::ast::StmtKind;
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct OpenFileWithContextHandler;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::define_violation;
|
||||
use crate::violation::Violation;
|
||||
use ruff_macros::derive_message_formats;
|
||||
use rustpython_ast::{Excepthandler, ExcepthandlerKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::define_violation;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
||||
define_violation!(
|
||||
pub struct ReturnInTryExceptFinally;
|
||||
|
|
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