Introduce a ruff_diagnostics crate (#3409)

## Summary

This PR moves `Diagnostic`, `DiagnosticKind`, and `Fix` into their own crate, which will enable us to further split up Ruff, since sub-linter crates (which need to implement functions that return `Diagnostic`) can now depend on `ruff_diagnostics` rather than Ruff.
This commit is contained in:
Charlie Marsh 2023-03-09 15:48:57 -05:00 committed by GitHub
parent 08ec11a31e
commit 024caca233
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
349 changed files with 758 additions and 1003 deletions

12
Cargo.lock generated
View file

@ -1982,6 +1982,7 @@ dependencies = [
"regex",
"result-like",
"ruff_cache",
"ruff_diagnostics",
"ruff_macros",
"ruff_python_ast",
"ruff_python_stdlib",
@ -2042,6 +2043,7 @@ dependencies = [
"regex",
"ruff",
"ruff_cache",
"ruff_diagnostics",
"rustc-hash",
"serde",
"serde_json",
@ -2067,6 +2069,7 @@ dependencies = [
"regex",
"ruff",
"ruff_cli",
"ruff_diagnostics",
"rustpython-common",
"rustpython-parser",
"schemars",
@ -2076,6 +2079,15 @@ dependencies = [
"textwrap",
]
[[package]]
name = "ruff_diagnostics"
version = "0.0.0"
dependencies = [
"ruff_python_ast",
"rustpython-parser",
"serde",
]
[[package]]
name = "ruff_formatter"
version = "0.0.0"

View file

@ -17,6 +17,7 @@ doctest = false
[dependencies]
ruff_cache = { path = "../ruff_cache" }
ruff_diagnostics = { path = "../ruff_diagnostics", features = ["serde"] }
ruff_macros = { path = "../ruff_macros" }
ruff_python_ast = { path = "../ruff_python_ast" }
ruff_python_stdlib = { path = "../ruff_python_stdlib" }

View file

@ -6,15 +6,15 @@ use libcst_native::{
use rustpython_parser::ast::{ExcepthandlerKind, Expr, Keyword, Location, Stmt, StmtKind};
use rustpython_parser::{lexer, Mode, Tok};
use crate::cst::helpers::compose_module_path;
use crate::cst::matchers::match_module;
use crate::fix::Fix;
use ruff_diagnostics::Fix;
use ruff_python_ast::helpers;
use ruff_python_ast::helpers::to_absolute;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
use ruff_python_ast::whitespace::LinesWithTrailingNewline;
use crate::cst::helpers::compose_module_path;
use crate::cst::matchers::match_module;
/// Determine if a body contains only a single statement, taking into account
/// deleted.
fn has_single_child(body: &[Stmt], deleted: &[&Stmt]) -> bool {
@ -450,9 +450,10 @@ mod tests {
use rustpython_parser as parser;
use rustpython_parser::ast::Location;
use crate::autofix::helpers::{next_stmt_break, trailing_semicolon};
use ruff_python_ast::source_code::Locator;
use crate::autofix::helpers::{next_stmt_break, trailing_semicolon};
#[test]
fn find_semicolon() -> Result<()> {
let contents = "x = 1";

View file

@ -4,12 +4,12 @@ use itertools::Itertools;
use rustc_hash::FxHashMap;
use rustpython_parser::ast::Location;
use ruff_diagnostics::{Diagnostic, Fix};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::fix::Fix;
use crate::linter::FixTable;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
pub mod helpers;
@ -96,43 +96,38 @@ pub(crate) fn apply_fix(fix: &Fix, locator: &Locator) -> String {
mod tests {
use rustpython_parser::ast::Location;
use ruff_diagnostics::Diagnostic;
use ruff_diagnostics::Fix;
use ruff_python_ast::source_code::Locator;
use crate::autofix::{apply_fix, apply_fixes};
use crate::fix::Fix;
use crate::registry::Diagnostic;
use crate::rules::pycodestyle::rules::NoNewLineAtEndOfFile;
#[test]
fn empty_file() {
let fixes: Vec<Diagnostic> = vec![];
let locator = Locator::new(r#""#);
let (contents, fixed) = apply_fixes(fixes.iter(), &locator);
assert_eq!(contents, "");
assert_eq!(fixed.values().sum::<usize>(), 0);
}
impl From<Fix> for Diagnostic {
fn from(fix: Fix) -> Self {
Diagnostic {
fn create_diagnostics(fixes: impl IntoIterator<Item = Fix>) -> Vec<Diagnostic> {
fixes
.into_iter()
.map(|fix| Diagnostic {
// The choice of rule here is arbitrary.
kind: NoNewLineAtEndOfFile.into(),
location: fix.location,
end_location: fix.end_location,
fix: Some(fix),
parent: None,
}
}
})
.collect()
}
#[test]
fn empty_file() {
let locator = Locator::new(r#""#);
let diagnostics = create_diagnostics([]);
let (contents, fixed) = apply_fixes(diagnostics.iter(), &locator);
assert_eq!(contents, "");
assert_eq!(fixed.values().sum::<usize>(), 0);
}
#[test]
fn apply_one_replacement() {
let fixes: Vec<Diagnostic> = vec![Fix {
content: "Bar".to_string(),
location: Location::new(1, 8),
end_location: Location::new(1, 14),
}
.into()];
let locator = Locator::new(
r#"
class A(object):
@ -140,7 +135,12 @@ class A(object):
"#
.trim(),
);
let (contents, fixed) = apply_fixes(fixes.iter(), &locator);
let diagnostics = create_diagnostics([Fix {
content: "Bar".to_string(),
location: Location::new(1, 8),
end_location: Location::new(1, 14),
}]);
let (contents, fixed) = apply_fixes(diagnostics.iter(), &locator);
assert_eq!(
contents,
r#"
@ -154,12 +154,6 @@ class A(Bar):
#[test]
fn apply_one_removal() {
let fixes: Vec<Diagnostic> = vec![Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
}
.into()];
let locator = Locator::new(
r#"
class A(object):
@ -167,7 +161,12 @@ class A(object):
"#
.trim(),
);
let (contents, fixed) = apply_fixes(fixes.iter(), &locator);
let diagnostics = create_diagnostics([Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
}]);
let (contents, fixed) = apply_fixes(diagnostics.iter(), &locator);
assert_eq!(
contents,
r#"
@ -181,20 +180,6 @@ class A:
#[test]
fn apply_two_removals() {
let fixes: Vec<Diagnostic> = vec![
Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 16),
}
.into(),
Fix {
content: String::new(),
location: Location::new(1, 16),
end_location: Location::new(1, 23),
}
.into(),
];
let locator = Locator::new(
r#"
class A(object, object):
@ -202,7 +187,19 @@ class A(object, object):
"#
.trim(),
);
let (contents, fixed) = apply_fixes(fixes.iter(), &locator);
let diagnostics = create_diagnostics([
Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 16),
},
Fix {
content: String::new(),
location: Location::new(1, 16),
end_location: Location::new(1, 23),
},
]);
let (contents, fixed) = apply_fixes(diagnostics.iter(), &locator);
assert_eq!(
contents,
@ -217,20 +214,6 @@ class A:
#[test]
fn ignore_overlapping_fixes() {
let fixes: Vec<Diagnostic> = vec![
Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
}
.into(),
Fix {
content: "ignored".to_string(),
location: Location::new(1, 9),
end_location: Location::new(1, 11),
}
.into(),
];
let locator = Locator::new(
r#"
class A(object):
@ -238,7 +221,19 @@ class A(object):
"#
.trim(),
);
let (contents, fixed) = apply_fixes(fixes.iter(), &locator);
let diagnostics = create_diagnostics([
Fix {
content: String::new(),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
},
Fix {
content: "ignored".to_string(),
location: Location::new(1, 9),
end_location: Location::new(1, 11),
},
]);
let (contents, fixed) = apply_fixes(diagnostics.iter(), &locator);
assert_eq!(
contents,
r#"

View file

@ -13,6 +13,7 @@ use rustpython_parser::ast::{
Suite,
};
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::context::Context;
use ruff_python_ast::helpers::{
binding_range, extract_handled_exceptions, to_module_path, Exceptions,
@ -36,7 +37,7 @@ use crate::checkers::ast::deferred::Deferred;
use crate::docstrings::definition::{
transition_scope, Definition, DefinitionKind, Docstring, Documentable,
};
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::registry::{AsRule, Rule};
use crate::rules::{
flake8_2020, flake8_annotations, flake8_bandit, flake8_blind_except, flake8_boolean_trap,
flake8_bugbear, flake8_builtins, flake8_comprehensions, flake8_datetimez, flake8_debugger,

View file

@ -1,6 +1,8 @@
use std::path::Path;
use crate::registry::{Diagnostic, Rule};
use ruff_diagnostics::Diagnostic;
use crate::registry::Rule;
use crate::rules::flake8_no_pep420::rules::implicit_namespace_package;
use crate::rules::pep8_naming::rules::invalid_module_name;
use crate::settings::Settings;

View file

@ -4,13 +4,15 @@ use std::path::Path;
use rustpython_parser::ast::Suite;
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
use ruff_python_ast::visitor::Visitor;
use crate::directives::IsortDirectives;
use crate::registry::{Diagnostic, Rule};
use crate::registry::Rule;
use crate::rules::isort;
use crate::rules::isort::track::{Block, ImportTracker};
use crate::settings::{flags, Settings};
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
use ruff_python_ast::visitor::Visitor;
#[allow(clippy::too_many_arguments)]
pub fn check_imports(

View file

@ -5,7 +5,11 @@ use itertools::Itertools;
use rustpython_parser::ast::Location;
use rustpython_parser::lexer::LexResult;
use crate::registry::{AsRule, Diagnostic, Rule};
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{Locator, Stylist};
use ruff_python_ast::types::Range;
use crate::registry::{AsRule, Rule};
use crate::rules::pycodestyle::logical_lines::{iter_logical_lines, TokenFlags};
use crate::rules::pycodestyle::rules::{
extraneous_whitespace, indentation, missing_whitespace, missing_whitespace_after_keyword,
@ -14,8 +18,6 @@ use crate::rules::pycodestyle::rules::{
whitespace_before_parameters,
};
use crate::settings::{flags, Settings};
use ruff_python_ast::source_code::{Locator, Stylist};
use ruff_python_ast::types::Range;
/// Return the amount of indentation, expanding tabs to the next multiple of 8.
fn expand_indent(mut line: &str) -> usize {
@ -225,9 +227,10 @@ mod tests {
use rustpython_parser::lexer::LexResult;
use rustpython_parser::{lexer, Mode};
use crate::checkers::logical_lines::iter_logical_lines;
use ruff_python_ast::source_code::Locator;
use crate::checkers::logical_lines::iter_logical_lines;
#[test]
fn split_logical_lines() {
let contents = r#"

View file

@ -4,13 +4,13 @@ use log::warn;
use nohash_hasher::IntMap;
use rustpython_parser::ast::Location;
use ruff_diagnostics::{Diagnostic, Fix};
use ruff_python_ast::types::Range;
use crate::codes::NoqaCode;
use crate::fix::Fix;
use crate::noqa;
use crate::noqa::{extract_file_exemption, Directive, Exemption};
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::registry::{AsRule, Rule};
use crate::rule_redirects::get_redirect_target;
use crate::rules::ruff::rules::{UnusedCodes, UnusedNOQA};
use crate::settings::{flags, Settings};

View file

@ -2,7 +2,10 @@
use std::path::Path;
use crate::registry::{Diagnostic, Rule};
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::Stylist;
use crate::registry::Rule;
use crate::rules::flake8_executable::helpers::{extract_shebang, ShebangDirective};
use crate::rules::flake8_executable::rules::{
shebang_missing, shebang_newline, shebang_not_executable, shebang_python, shebang_whitespace,
@ -15,7 +18,6 @@ use crate::rules::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore};
use crate::rules::pylint;
use crate::rules::pyupgrade::rules::unnecessary_coding_comment;
use crate::settings::{flags, Settings};
use ruff_python_ast::source_code::Stylist;
pub fn check_physical_lines(
path: &Path,
@ -179,13 +181,14 @@ pub fn check_physical_lines(
#[cfg(test)]
mod tests {
use std::path::Path;
use super::check_physical_lines;
use ruff_python_ast::source_code::{Locator, Stylist};
use crate::registry::Rule;
use crate::settings::{flags, Settings};
use ruff_python_ast::source_code::{Locator, Stylist};
use super::check_physical_lines;
#[test]
fn e501_non_ascii_char() {

View file

@ -4,13 +4,14 @@ use rustpython_parser::lexer::LexResult;
use rustpython_parser::Tok;
use crate::lex::docstring_detection::StateMachine;
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::registry::{AsRule, Rule};
use crate::rules::ruff::rules::Context;
use crate::rules::{
eradicate, flake8_commas, flake8_implicit_str_concat, flake8_pyi, flake8_quotes, pycodestyle,
pyupgrade, ruff,
};
use crate::settings::{flags, Settings};
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::Locator;
pub fn check_tokens(

View file

@ -1,6 +1,3 @@
use rustpython_parser::ast::Location;
use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, Hash)]
pub enum FixMode {
Generate,
@ -18,40 +15,3 @@ impl From<bool> for FixMode {
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Fix {
pub content: String,
pub location: Location,
pub end_location: Location,
}
impl Fix {
pub const fn deletion(start: Location, end: Location) -> Self {
Self {
content: String::new(),
location: start,
end_location: end,
}
}
pub fn replacement(content: String, start: Location, end: Location) -> Self {
debug_assert!(!content.is_empty(), "Prefer `Fix::deletion`");
Self {
content,
location: start,
end_location: end,
}
}
pub fn insertion(content: String, at: Location) -> Self {
debug_assert!(!content.is_empty(), "Insert content is empty");
Self {
content,
location: at,
end_location: at,
}
}
}

View file

@ -9,7 +9,6 @@ pub use ruff_python_ast::source_code::round_trip;
pub use ruff_python_ast::types::Range;
pub use rule_selector::RuleSelector;
pub use rules::pycodestyle::rules::IOError;
pub use violation::{AutofixKind, Availability as AutofixAvailability};
mod autofix;
mod checkers;
@ -33,7 +32,6 @@ mod rule_redirects;
mod rule_selector;
pub mod rules;
pub mod settings;
mod violation;
#[cfg(test)]
mod test;

View file

@ -4,11 +4,14 @@ use std::path::Path;
use anyhow::{anyhow, Result};
use colored::Colorize;
use log::error;
use ruff_python_stdlib::path::is_python_stub_file;
use rustc_hash::FxHashMap;
use rustpython_parser::lexer::LexResult;
use rustpython_parser::ParseError;
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
use ruff_python_stdlib::path::is_python_stub_file;
use crate::autofix::fix_file;
use crate::checkers::ast::check_ast;
use crate::checkers::filesystem::check_file_path;
@ -21,11 +24,10 @@ use crate::directives::Directives;
use crate::doc_lines::{doc_lines_from_ast, doc_lines_from_tokens};
use crate::message::{Message, Source};
use crate::noqa::{add_noqa, rule_is_ignored};
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::registry::{AsRule, Rule};
use crate::rules::pycodestyle;
use crate::settings::{flags, Settings};
use crate::{directives, fs};
use ruff_python_ast::source_code::{Indexer, Locator, Stylist};
const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME");
const CARGO_PKG_REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY");

View file

@ -3,8 +3,7 @@ use std::cmp::Ordering;
pub use rustpython_parser::ast::Location;
use serde::{Deserialize, Serialize};
use crate::fix::Fix;
use crate::registry::{Diagnostic, DiagnosticKind};
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Fix};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;

View file

@ -11,11 +11,12 @@ use regex::Regex;
use rustc_hash::{FxHashMap, FxHashSet};
use rustpython_parser::ast::Location;
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::{LineEnding, Locator};
use ruff_python_ast::types::Range;
use crate::codes::NoqaCode;
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::registry::{AsRule, Rule};
use crate::rule_redirects::get_redirect_target;
static NOQA_LINE_REGEX: Lazy<Regex> = Lazy::new(|| {
@ -333,11 +334,11 @@ mod tests {
use nohash_hasher::IntMap;
use rustpython_parser::ast::Location;
use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::LineEnding;
use ruff_python_ast::types::Range;
use crate::noqa::{add_noqa_inner, NOQA_LINE_REGEX};
use crate::registry::Diagnostic;
use crate::rules::pycodestyle::rules::AmbiguousVariableName;
use crate::rules::pyflakes;

View file

@ -1,16 +1,12 @@
//! Registry of [`Rule`] to [`DiagnosticKind`] mappings.
//! Registry of all [`Rule`] implementations.
use rustpython_parser::ast::Location;
use serde::{Deserialize, Serialize};
use strum_macros::{AsRefStr, EnumIter};
use ruff_diagnostics::Violation;
use ruff_macros::RuleNamespace;
use ruff_python_ast::types::Range;
use crate::codes::{self, RuleCodePrefix};
use crate::fix::Fix;
use crate::rules;
use crate::violation::Violation;
ruff_macros::register_rules!(
// pycodestyle errors
@ -899,49 +895,6 @@ impl Rule {
}
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DiagnosticKind {
/// The identifier of the corresponding [`Rule`].
pub name: String,
/// The message body to display to the user, to explain the diagnostic.
pub body: String,
/// The message to display to the user, to explain the suggested fix.
pub suggestion: Option<String>,
/// Whether the diagnostic is automatically fixable.
pub fixable: bool,
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Diagnostic {
pub kind: DiagnosticKind,
pub location: Location,
pub end_location: Location,
pub fix: Option<Fix>,
pub parent: Option<Location>,
}
impl Diagnostic {
pub fn new<K: Into<DiagnosticKind>>(kind: K, range: Range) -> Self {
Self {
kind: kind.into(),
location: range.location,
end_location: range.end_location,
fix: None,
parent: None,
}
}
pub fn amend(&mut self, fix: Fix) -> &mut Self {
self.fix = Some(fix);
self
}
pub fn parent(&mut self, parent: Location) -> &mut Self {
self.parent = Some(parent);
self
}
}
/// Pairs of checks that shouldn't be enabled together.
pub const INCOMPATIBLE_CODES: &[(Rule, Rule, &str); 2] = &[
(

View file

@ -1,13 +1,12 @@
use rustpython_parser::ast::Location;
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::fix::Fix;
use crate::registry::{Diagnostic, Rule};
use crate::registry::Rule;
use crate::settings::{flags, Settings};
use crate::violation::AlwaysAutofixableViolation;
use super::detection::comment_contains_code;

View file

@ -1,12 +1,12 @@
use num_bigint::BigInt;
use rustpython_parser::ast::{Cmpop, Constant, Expr, ExprKind, Located};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{Diagnostic, Rule};
use crate::violation::Violation;
use crate::registry::Rule;
#[violation]
pub struct SysVersionSlice3Referenced;

View file

@ -2,11 +2,10 @@ use anyhow::{bail, Result};
use rustpython_parser::ast::Stmt;
use rustpython_parser::{lexer, Mode, Tok};
use ruff_diagnostics::Fix;
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::fix::Fix;
/// ANN204
pub fn add_return_none_annotation(locator: &Locator, stmt: &Stmt) -> Result<Fix> {
let range = Range::from(stmt);

View file

@ -1,6 +1,7 @@
use log::error;
use rustpython_parser::ast::{Constant, Expr, ExprKind, Stmt};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::ReturnStatementVisitor;
use ruff_python_ast::types::Range;
@ -11,8 +12,7 @@ use ruff_python_ast::{cast, helpers};
use crate::checkers::ast::Checker;
use crate::docstrings::definition::{Definition, DefinitionKind};
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::violation::{AlwaysAutofixableViolation, Violation};
use crate::registry::{AsRule, Rule};
use super::fixes;
use super::helpers::match_function_def;

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::Stmt;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct Assert;

View file

@ -3,13 +3,12 @@ use once_cell::sync::Lazy;
use rustc_hash::FxHashMap;
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword, Operator};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::{compose_call_path, SimpleCallArgs};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct BadFilePermissions {

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct ExecBuiltin;

View file

@ -1,9 +1,7 @@
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct HardcodedBindAllInterfaces;

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::{Arg, Arguments, Expr};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::super::helpers::{matches_password_name, string_literal};
#[violation]

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::Keyword;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::super::helpers::{matches_password_name, string_literal};
#[violation]

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::super::helpers::{matches_password_name, string_literal};
#[violation]

View file

@ -2,13 +2,12 @@ use once_cell::sync::Lazy;
use regex::Regex;
use rustpython_parser::ast::{Expr, ExprKind, Operator};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::{any_over_expr, unparse_expr};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::super::helpers::string_literal;

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::Expr;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct HardcodedTempFile {
pub string: String,

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::super::helpers::string_literal;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct Jinja2AutoescapeFalse {

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Expr, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct LoggingConfigInsecureListen;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct RequestWithNoCertValidation {

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::{unparse_constant, SimpleCallArgs};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct RequestWithoutTimeout {

View file

@ -1,13 +1,12 @@
use num_traits::{One, Zero};
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct SnmpInsecureVersion;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Expr, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct SnmpWeakCryptography;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Excepthandler, Expr, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::rules::flake8_bandit::helpers::is_untyped_exception;
use crate::violation::Violation;
#[violation]
pub struct TryExceptContinue;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Excepthandler, Expr, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::rules::flake8_bandit::helpers::is_untyped_exception;
use crate::violation::Violation;
#[violation]
pub struct TryExceptPass;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::SimpleCallArgs;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UnsafeYAMLLoad {

View file

@ -1,13 +1,12 @@
use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers;
use ruff_python_ast::helpers::{find_keyword, is_const_true};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct BlindExcept {

View file

@ -1,12 +1,12 @@
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind};
use ruff_diagnostics::Violation;
use ruff_diagnostics::{Diagnostic, DiagnosticKind};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::collect_call_path;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{Diagnostic, DiagnosticKind};
use crate::violation::Violation;
#[violation]
pub struct BooleanPositionalArgInFunctionDefinition;

View file

@ -1,12 +1,12 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use ruff_python_ast::visibility::{is_abstract, is_overload};
use crate::checkers::ast::Checker;
use crate::registry::{Diagnostic, Rule};
use crate::violation::Violation;
use crate::registry::Rule;
#[violation]
pub struct AbstractBaseClassWithoutAbstractMethod {

View file

@ -1,13 +1,12 @@
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::unparse_stmt;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic};
use crate::violation::AlwaysAutofixableViolation;
use crate::registry::AsRule;
#[violation]
pub struct AssertFalse;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{ExprKind, Stmt, Withitem};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
/// ## What it does
/// Checks for `self.assertRaises(Exception)`.

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct AssignmentToOsEnviron;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::{Range, ScopeKind};
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct CachedInstanceMethod;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct CannotRaiseLiteral;

View file

@ -4,15 +4,15 @@ use rustpython_parser::ast::{
Excepthandler, ExcepthandlerKind, Expr, ExprContext, ExprKind, Location,
};
use ruff_diagnostics::{AlwaysAutofixableViolation, Violation};
use ruff_diagnostics::{Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers;
use ruff_python_ast::helpers::unparse_expr;
use ruff_python_ast::types::{CallPath, Range};
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic, Rule};
use crate::violation::{AlwaysAutofixableViolation, Violation};
use crate::registry::{AsRule, Rule};
#[violation]
pub struct DuplicateTryBlockException {

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::Excepthandler;
use rustpython_parser::ast::{ExcepthandlerKind, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct ExceptWithEmptyTuple;

View file

@ -2,12 +2,11 @@ use std::collections::VecDeque;
use rustpython_parser::ast::{Excepthandler, ExcepthandlerKind, Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct ExceptWithNonExceptionClasses;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct FStringDocstring;

View file

@ -1,5 +1,7 @@
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind};
use ruff_diagnostics::Violation;
use ruff_diagnostics::{Diagnostic, DiagnosticKind};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::{compose_call_path, to_call_path};
use ruff_python_ast::types::{CallPath, Range};
@ -7,8 +9,6 @@ use ruff_python_ast::visitor;
use ruff_python_ast::visitor::Visitor;
use crate::checkers::ast::Checker;
use crate::registry::{Diagnostic, DiagnosticKind};
use crate::violation::Violation;
use super::mutable_argument_default::is_mutable_func;

View file

@ -1,6 +1,7 @@
use rustc_hash::FxHashSet;
use rustpython_parser::ast::{Comprehension, Expr, ExprContext, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::collect_arg_names;
use ruff_python_ast::types::{Node, Range};
@ -8,8 +9,6 @@ use ruff_python_ast::visitor;
use ruff_python_ast::visitor::Visitor;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct FunctionUsesLoopVariable {

View file

@ -1,5 +1,6 @@
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::unparse_expr;
use ruff_python_ast::types::Range;
@ -7,9 +8,7 @@ use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
use ruff_python_stdlib::keyword::KWLIST;
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic};
use crate::violation::AlwaysAutofixableViolation;
use crate::registry::AsRule;
#[violation]
pub struct GetAttrWithConstant;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct JumpStatementInFinally {

View file

@ -1,14 +1,13 @@
use rustc_hash::FxHashMap;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use ruff_python_ast::visitor;
use ruff_python_ast::visitor::Visitor;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct LoopVariableOverridesIterator {

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Arguments, Constant, Expr, ExprKind, Operator};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct MutableArgumentDefault;

View file

@ -1,13 +1,12 @@
use rustpython_parser::ast::{ExprKind, Stmt};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::RaiseStatementVisitor;
use ruff_python_ast::visitor;
use ruff_python_stdlib::str::is_lower;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct RaiseWithoutFromInsideExcept;

View file

@ -1,13 +1,12 @@
use rustpython_parser::ast::{Excepthandler, ExcepthandlerKind, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::unparse_expr;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic};
use crate::violation::AlwaysAutofixableViolation;
use crate::registry::AsRule;
#[violation]
pub struct RedundantTupleInExceptionHandler {

View file

@ -1,5 +1,6 @@
use rustpython_parser::ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, StmtKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::unparse_stmt;
use ruff_python_ast::source_code::Stylist;
@ -8,9 +9,7 @@ use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
use ruff_python_stdlib::keyword::KWLIST;
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic};
use crate::violation::AlwaysAutofixableViolation;
use crate::registry::AsRule;
#[violation]
pub struct SetAttrWithConstant;

View file

@ -9,12 +9,11 @@
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct StarArgUnpackingAfterKeywordArg;

View file

@ -1,12 +1,11 @@
use itertools::Itertools;
use rustpython_parser::ast::{Constant, Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct StripWithMultiCharacters;

View file

@ -19,12 +19,11 @@
use rustpython_parser::ast::{Expr, ExprKind, Unaryop};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UnaryPrefixIncrement;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind, Stmt};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
/// ## What it does
/// Checks for the unintentional use of type annotations.

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UnreliableCallableCheck;

View file

@ -22,15 +22,14 @@ use rustc_hash::FxHashMap;
use rustpython_parser::ast::{Expr, ExprKind, Stmt};
use serde::{Deserialize, Serialize};
use ruff_diagnostics::{AutofixKind, Availability, Diagnostic, Fix, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::{Range, RefEquality};
use ruff_python_ast::visitor::Visitor;
use ruff_python_ast::{helpers, visitor};
use crate::checkers::ast::Checker;
use crate::fix::Fix;
use crate::registry::{AsRule, Diagnostic};
use crate::violation::{AutofixKind, Availability, Violation};
use crate::registry::AsRule;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, result_like::BoolLike)]
pub enum Certainty {

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UselessComparison;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::Expr;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UselessContextlibSuppress;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Constant, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct UselessExpression;

View file

@ -1,11 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct ZipWithoutExplicitStrict;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::Located;
use ruff_diagnostics::Violation;
use ruff_diagnostics::{Diagnostic, DiagnosticKind};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use ruff_python_stdlib::builtins::BUILTINS;
use crate::registry::{Diagnostic, DiagnosticKind};
use crate::violation::Violation;
use super::types::ShadowingType;
/// ## What it does

View file

@ -2,14 +2,14 @@ use itertools::Itertools;
use rustpython_parser::lexer::{LexResult, Spanned};
use rustpython_parser::Tok;
use ruff_diagnostics::{AlwaysAutofixableViolation, Violation};
use ruff_diagnostics::{Diagnostic, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::fix::Fix;
use crate::registry::{Diagnostic, Rule};
use crate::registry::Rule;
use crate::settings::{flags, Settings};
use crate::violation::{AlwaysAutofixableViolation, Violation};
/// Simplified token type.
#[derive(Copy, Clone, PartialEq, Eq)]

View file

@ -7,10 +7,10 @@ use libcst_native::{
RightParen, RightSquareBracket, Set, SetComp, SimpleString, SimpleWhitespace, Tuple,
};
use ruff_diagnostics::Fix;
use ruff_python_ast::source_code::{Locator, Stylist};
use crate::cst::matchers::{match_expr, match_module};
use crate::fix::Fix;
fn match_call<'a, 'b>(expr: &'a mut Expr<'b>) -> Result<&'a mut Call<'b>> {
if let Expression::Call(call) = &mut expr.value {

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,14 +1,14 @@
use log::error;
use rustpython_parser::ast::{Expr, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::rules::flake8_comprehensions::settings::Settings;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Comprehension, Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,12 +1,12 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,13 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::AlwaysAutofixableViolation;
use super::helpers;

View file

@ -1,13 +1,14 @@
use log::error;
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::Diagnostic;
use ruff_diagnostics::{AutofixKind, Availability, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
use crate::rules::flake8_comprehensions::fixes;
use crate::violation::{AutofixKind, Availability, Violation};
use super::helpers;

View file

@ -1,12 +1,11 @@
use num_bigint::BigInt;
use rustpython_parser::ast::{Constant, Expr, ExprKind, Unaryop};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::helpers;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::{has_non_none_keyword, is_const_none};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
#[violation]
pub struct CallDatetimeWithoutTzinfo;

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Expr, Stmt};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::helpers::format_call_path;
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::types::DebuggerUsingType;

View file

@ -1,11 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::rules::flake8_django::rules::helpers::is_model_form;
use crate::violation::Violation;
use crate::{checkers::ast::Checker, registry::Diagnostic};
/// ## What it does
/// Checks for the use of `fields = "__all__"` in Django `ModelForm`

View file

@ -1,11 +1,11 @@
use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::rules::flake8_django::rules::helpers::is_model_form;
use crate::violation::Violation;
use crate::{checkers::ast::Checker, registry::Diagnostic};
/// ## What it does
/// Checks for the use of `exclude` in Django `ModelForm` classes.

View file

@ -1,9 +1,10 @@
use rustpython_parser::ast::{Expr, ExprKind, Keyword};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::{checkers::ast::Checker, registry::Diagnostic, violation::Violation};
use crate::checkers::ast::Checker;
/// ## What it does
/// Checks for the use of `locals()` in `render` functions.

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, StmtKind};
use rustpython_parser::ast::{ExprKind, Stmt};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::helpers;

View file

@ -1,11 +1,9 @@
use rustpython_parser::ast::{Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::{CallPath, Range};
use crate::registry::Diagnostic;
use crate::violation::Violation;
/// ## What it does
/// Checks that Django's `@receiver` decorator is listed first, prior to
/// any other decorators.

View file

@ -1,12 +1,11 @@
use rustpython_parser::ast::Constant::Bool;
use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::Diagnostic;
use crate::violation::Violation;
use super::helpers;

View file

@ -1,11 +1,11 @@
use rustpython_parser::ast::{Constant, Expr, ExprKind};
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::checkers::ast::Checker;
use crate::registry::{Diagnostic, Rule};
use crate::violation::Violation;
use crate::registry::Rule;
/// ## What it does
/// Checks for the use of string literals in exception constructors.

View file

@ -2,13 +2,13 @@
use std::path::Path;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::registry::{AsRule, Diagnostic};
use crate::registry::AsRule;
#[cfg(target_family = "unix")]
use crate::rules::flake8_executable::helpers::is_executable;
use crate::violation::Violation;
#[violation]
pub struct ShebangMissingExecutableFile;

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