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