mirror of https://github.com/astral-sh/ruff
structs 8/9: Run cargo fix and cargo fmt
This commit is contained in:
parent
6208eb7bbf
commit
6a723b50c7
|
|
@ -9,7 +9,6 @@ use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::registry::Check;
|
use crate::registry::Check;
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::violations;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash)]
|
#[derive(Debug, Copy, Clone, Hash)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ use crate::python::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||||
use crate::python::future::ALL_FEATURE_NAMES;
|
use crate::python::future::ALL_FEATURE_NAMES;
|
||||||
use crate::python::typing;
|
use crate::python::typing;
|
||||||
use crate::python::typing::SubscriptKind;
|
use crate::python::typing::SubscriptKind;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind, DeferralKeyword};
|
use crate::registry::{Check, CheckCode, DeferralKeyword};
|
||||||
use crate::settings::types::PythonVersion;
|
use crate::settings::types::PythonVersion;
|
||||||
use crate::settings::{flags, Settings};
|
use crate::settings::{flags, Settings};
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ use rustpython_parser::ast::Suite;
|
||||||
|
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::directives::IsortDirectives;
|
use crate::directives::IsortDirectives;
|
||||||
|
use crate::isort;
|
||||||
use crate::isort::track::ImportTracker;
|
use crate::isort::track::ImportTracker;
|
||||||
use crate::registry::Check;
|
use crate::registry::Check;
|
||||||
use crate::settings::{flags, Settings};
|
use crate::settings::{flags, Settings};
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::source_code_style::SourceCodeStyleDetector;
|
use crate::source_code_style::SourceCodeStyleDetector;
|
||||||
use crate::{isort, violations};
|
|
||||||
|
|
||||||
fn check_import_blocks(
|
fn check_import_blocks(
|
||||||
tracker: ImportTracker,
|
tracker: ImportTracker,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ use crate::pygrep_hooks::plugins::{blanket_noqa, blanket_type_ignore};
|
||||||
use crate::pyupgrade::checks::unnecessary_coding_comment;
|
use crate::pyupgrade::checks::unnecessary_coding_comment;
|
||||||
use crate::registry::{Check, CheckCode};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::settings::{flags, Settings};
|
use crate::settings::{flags, Settings};
|
||||||
use crate::violations;
|
|
||||||
|
|
||||||
pub fn check_lines(
|
pub fn check_lines(
|
||||||
contents: &str,
|
contents: &str,
|
||||||
|
|
@ -83,7 +82,6 @@ mod tests {
|
||||||
use super::check_lines;
|
use super::check_lines;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::settings::{flags, Settings};
|
use crate::settings::{flags, Settings};
|
||||||
use crate::violations;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn e501_non_ascii_char() {
|
fn e501_non_ascii_char() {
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ use crate::registry::{Check, CheckCode};
|
||||||
use crate::ruff::checks::Context;
|
use crate::ruff::checks::Context;
|
||||||
use crate::settings::flags;
|
use crate::settings::flags;
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::{
|
use crate::{eradicate, flake8_implicit_str_concat, flake8_quotes, pycodestyle, ruff, Settings};
|
||||||
eradicate, flake8_implicit_str_concat, flake8_quotes, pycodestyle, ruff, violations, Settings,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn check_tokens(
|
pub fn check_tokens(
|
||||||
locator: &SourceCodeLocator,
|
locator: &SourceCodeLocator,
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ use clap::{command, Parser};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
|
use crate::fs;
|
||||||
use crate::logging::LogLevel;
|
use crate::logging::LogLevel;
|
||||||
use crate::registry::{CheckCode, CheckCodePrefix};
|
use crate::registry::{CheckCode, CheckCodePrefix};
|
||||||
use crate::settings::types::{
|
use crate::settings::types::{
|
||||||
FilePattern, PatternPrefixPair, PerFileIgnore, PythonVersion, SerializationFormat,
|
FilePattern, PatternPrefixPair, PerFileIgnore, PythonVersion, SerializationFormat,
|
||||||
};
|
};
|
||||||
use crate::{fs, violations};
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(author, about = "Ruff: An extremely fast Python linter.")]
|
#[command(author, about = "Ruff: An extremely fast Python linter.")]
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use crate::iterators::par_iter;
|
||||||
use crate::linter::{add_noqa_to_path, lint_path, lint_stdin, Diagnostics};
|
use crate::linter::{add_noqa_to_path, lint_path, lint_stdin, Diagnostics};
|
||||||
use crate::logging::LogLevel;
|
use crate::logging::LogLevel;
|
||||||
use crate::message::Message;
|
use crate::message::Message;
|
||||||
use crate::registry::{CheckCode, CheckKind};
|
use crate::registry::CheckCode;
|
||||||
use crate::resolver::{FileDiscovery, PyprojectDiscovery};
|
use crate::resolver::{FileDiscovery, PyprojectDiscovery};
|
||||||
use crate::settings::flags;
|
use crate::settings::flags;
|
||||||
use crate::settings::types::SerializationFormat;
|
use crate::settings::types::SerializationFormat;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use rustpython_ast::Location;
|
||||||
use rustpython_parser::lexer::{LexResult, Tok};
|
use rustpython_parser::lexer::{LexResult, Tok};
|
||||||
|
|
||||||
use crate::registry::LintSource;
|
use crate::registry::LintSource;
|
||||||
use crate::{violations, Settings};
|
use crate::Settings;
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
pub struct Flags: u32 {
|
pub struct Flags: u32 {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::Location;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::eradicate::detection::comment_contains_code;
|
use crate::eradicate::detection::comment_contains_code;
|
||||||
use crate::registry::{CheckCode, CheckKind};
|
use crate::registry::CheckCode;
|
||||||
use crate::settings::flags;
|
use crate::settings::flags;
|
||||||
use crate::{violations, Check, Settings, SourceCodeLocator};
|
use crate::{violations, Check, Settings, SourceCodeLocator};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::ERA001, Path::new("ERA001.py"); "ERA001")]
|
#[test_case(CheckCode::ERA001, Path::new("ERA001.py"); "ERA001")]
|
||||||
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::YTT101, Path::new("YTT101.py"); "YTT101")]
|
#[test_case(CheckCode::YTT101, Path::new("YTT101.py"); "YTT101")]
|
||||||
#[test_case(CheckCode::YTT102, Path::new("YTT102.py"); "YTT102")]
|
#[test_case(CheckCode::YTT102, Path::new("YTT102.py"); "YTT102")]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_ast::{Cmpop, Constant, Expr, ExprKind, Located};
|
||||||
use crate::ast::helpers::match_module_member;
|
use crate::ast::helpers::match_module_member;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_sys(checker: &Checker, expr: &Expr, target: &str) -> bool {
|
fn is_sys(checker: &Checker, expr: &Expr, target: &str) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_annotations, violations, Settings};
|
use crate::{flake8_annotations, Settings};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn defaults() -> Result<()> {
|
fn defaults() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::checkers::ast::Checker;
|
||||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||||
use crate::flake8_annotations::fixes;
|
use crate::flake8_annotations::fixes;
|
||||||
use crate::flake8_annotations::helpers::match_function_def;
|
use crate::flake8_annotations::helpers::match_function_def;
|
||||||
use crate::registry::{CheckCode, CheckKind};
|
use crate::registry::CheckCode;
|
||||||
use crate::visibility::Visibility;
|
use crate::visibility::Visibility;
|
||||||
use crate::{violations, visibility, Check};
|
use crate::{violations, visibility, Check};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use rustpython_ast::{Located, StmtKind};
|
use rustpython_ast::{Located, StmtKind};
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S101
|
/// S101
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use rustpython_ast::{Constant, Expr, ExprKind, Keyword, Operator};
|
||||||
|
|
||||||
use crate::ast::helpers::{compose_call_path, match_module_member, SimpleCallArgs};
|
use crate::ast::helpers::{compose_call_path, match_module_member, SimpleCallArgs};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const WRITE_WORLD: u16 = 0o2;
|
const WRITE_WORLD: u16 = 0o2;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use rustpython_ast::{Expr, ExprKind};
|
use rustpython_ast::{Expr, ExprKind};
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S102
|
/// S102
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S104
|
/// S104
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustpython_ast::{ArgData, Arguments, Expr, Located};
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn check_password_kwarg(arg: &Located<ArgData>, default: &Expr) -> Option<Check> {
|
fn check_password_kwarg(arg: &Located<ArgData>, default: &Expr) -> Option<Check> {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustpython_ast::Keyword;
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S106
|
/// S106
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustpython_ast::{Constant, Expr, ExprKind};
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_password_target(target: &Expr) -> bool {
|
fn is_password_target(target: &Expr) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use rustpython_ast::Expr;
|
use rustpython_ast::Expr;
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S108
|
/// S108
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_ast::{Constant, Expr, ExprKind, Keyword};
|
||||||
use crate::ast::helpers::{match_module_member, SimpleCallArgs};
|
use crate::ast::helpers::{match_module_member, SimpleCallArgs};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_bandit::helpers::string_literal;
|
use crate::flake8_bandit::helpers::string_literal;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const WEAK_HASHES: [&str; 4] = ["md4", "md5", "sha", "sha1"];
|
const WEAK_HASHES: [&str; 4] = ["md4", "md5", "sha", "sha1"];
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::Constant;
|
||||||
|
|
||||||
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path, SimpleCallArgs};
|
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path, SimpleCallArgs};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const REQUESTS_HTTP_VERBS: [&str; 7] = ["get", "options", "head", "post", "put", "patch", "delete"];
|
const REQUESTS_HTTP_VERBS: [&str; 7] = ["get", "options", "head", "post", "put", "patch", "delete"];
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::Constant;
|
||||||
|
|
||||||
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path, SimpleCallArgs};
|
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path, SimpleCallArgs};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const HTTP_VERBS: [&str; 7] = ["get", "options", "head", "post", "put", "patch", "delete"];
|
const HTTP_VERBS: [&str; 7] = ["get", "options", "head", "post", "put", "patch", "delete"];
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Expr, ExprKind, Keyword};
|
||||||
|
|
||||||
use crate::ast::helpers::{match_module_member, SimpleCallArgs};
|
use crate::ast::helpers::{match_module_member, SimpleCallArgs};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// S506
|
/// S506
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_bandit, violations, Settings};
|
use crate::{flake8_bandit, Settings};
|
||||||
|
|
||||||
#[test_case(CheckCode::S101, Path::new("S101.py"); "S101")]
|
#[test_case(CheckCode::S101, Path::new("S101.py"); "S101")]
|
||||||
#[test_case(CheckCode::S102, Path::new("S102.py"); "S102")]
|
#[test_case(CheckCode::S102, Path::new("S102.py"); "S102")]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::BLE001, Path::new("BLE.py"); "BLE001")]
|
#[test_case(CheckCode::BLE001, Path::new("BLE.py"); "BLE001")]
|
||||||
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustpython_ast::{Expr, 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// BLE001
|
/// BLE001
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::FBT001, Path::new("FBT.py"); "FBT001")]
|
#[test_case(CheckCode::FBT001, Path::new("FBT.py"); "FBT001")]
|
||||||
#[test_case(CheckCode::FBT002, Path::new("FBT.py"); "FBT002")]
|
#[test_case(CheckCode::FBT002, Path::new("FBT.py"); "FBT002")]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_bugbear, violations, Settings};
|
use crate::{flake8_bugbear, Settings};
|
||||||
|
|
||||||
#[test_case(CheckCode::B002, Path::new("B002.py"); "B002")]
|
#[test_case(CheckCode::B002, Path::new("B002.py"); "B002")]
|
||||||
#[test_case(CheckCode::B003, Path::new("B003.py"); "B003")]
|
#[test_case(CheckCode::B003, Path::new("B003.py"); "B003")]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_ast::{Constant, Expr, ExprKind, Keyword, Stmt, StmtKind};
|
||||||
use crate::ast::helpers::match_module_member;
|
use crate::ast::helpers::match_module_member;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_abc_class(
|
fn is_abc_class(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Location, Stmt, Stmt
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{ExprKind, Stmt, Withitem};
|
||||||
use crate::ast::helpers::match_module_member;
|
use crate::ast::helpers::match_module_member;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B017
|
/// B017
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B003
|
/// B003
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Expr, ExprKind};
|
||||||
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
||||||
use crate::ast::types::{Range, ScopeKind};
|
use crate::ast::types::{Range, ScopeKind};
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_cache_func(checker: &Checker, expr: &Expr) -> bool {
|
fn is_cache_func(checker: &Checker, expr: &Expr) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B016
|
/// B016
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::helpers;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B021
|
/// B021
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::types::{Node, Range};
|
||||||
use crate::ast::visitor;
|
use crate::ast::visitor;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::python::identifiers::IDENTIFIER_REGEX;
|
use crate::python::identifiers::IDENTIFIER_REGEX;
|
||||||
use crate::python::keyword::KWLIST;
|
use crate::python::keyword::KWLIST;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn walk_stmt(checker: &mut Checker, body: &[Stmt], f: fn(&Stmt) -> bool) {
|
fn walk_stmt(checker: &mut Checker, body: &[Stmt], f: fn(&Stmt) -> bool) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::ast::types::Range;
|
||||||
use crate::ast::visitor;
|
use crate::ast::visitor;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_ast::{Arguments, Constant, Expr, ExprKind, Operator};
|
||||||
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const MUTABLE_FUNCS: &[(&str, &str)] = &[
|
const MUTABLE_FUNCS: &[(&str, &str)] = &[
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ 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::python::string::is_lower;
|
use crate::python::string::is_lower;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
struct RaiseVisitor {
|
struct RaiseVisitor {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Excepthandler, ExcepthandlerKind, ExprKind};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::python::identifiers::IDENTIFIER_REGEX;
|
use crate::python::identifiers::IDENTIFIER_REGEX;
|
||||||
use crate::python::keyword::KWLIST;
|
use crate::python::keyword::KWLIST;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::source_code_style::SourceCodeStyleDetector;
|
use crate::source_code_style::SourceCodeStyleDetector;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B026
|
/// B026
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B005
|
/// B005
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B002
|
/// B002
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B004
|
/// B004
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::visitor;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// Identify all `ExprKind::Name` nodes in an AST.
|
/// Identify all `ExprKind::Name` nodes in an AST.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
pub fn useless_comparison(checker: &mut Checker, expr: &Expr) {
|
pub fn useless_comparison(checker: &mut Checker, expr: &Expr) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::Expr;
|
||||||
use crate::ast::helpers::{collect_call_paths, match_call_path};
|
use crate::ast::helpers::{collect_call_paths, match_call_path};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B005
|
/// B005
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
// B018
|
// B018
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// B905
|
/// B905
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::A001, Path::new("A001.py"); "A001")]
|
#[test_case(CheckCode::A001, Path::new("A001.py"); "A001")]
|
||||||
#[test_case(CheckCode::A002, Path::new("A002.py"); "A002")]
|
#[test_case(CheckCode::A002, Path::new("A002.py"); "A002")]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use rustpython_ast::{
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_comprehensions::fixes;
|
use crate::flake8_comprehensions::fixes;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::C400, Path::new("C400.py"); "C400")]
|
#[test_case(CheckCode::C400, Path::new("C400.py"); "C400")]
|
||||||
#[test_case(CheckCode::C401, Path::new("C401.py"); "C401")]
|
#[test_case(CheckCode::C401, Path::new("C401.py"); "C401")]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::DTZ001, Path::new("DTZ001.py"); "DTZ001")]
|
#[test_case(CheckCode::DTZ001, Path::new("DTZ001.py"); "DTZ001")]
|
||||||
#[test_case(CheckCode::DTZ002, Path::new("DTZ002.py"); "DTZ002")]
|
#[test_case(CheckCode::DTZ002, Path::new("DTZ002.py"); "DTZ002")]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::ast::helpers::{
|
||||||
};
|
};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
pub fn call_datetime_without_tzinfo(
|
pub fn call_datetime_without_tzinfo(
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use rustpython_ast::{Expr, Stmt};
|
||||||
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
use crate::ast::helpers::{collect_call_paths, dealias_call_path, match_call_path};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_debugger::types::DebuggerUsingType;
|
use crate::flake8_debugger::types::DebuggerUsingType;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const DEBUGGERS: &[(&str, &str)] = &[
|
const DEBUGGERS: &[(&str, &str)] = &[
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::T100, Path::new("T100.py"); "T100")]
|
#[test_case(CheckCode::T100, Path::new("T100.py"); "T100")]
|
||||||
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
fn checks(check_code: CheckCode, path: &Path) -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_errmsg, settings, violations};
|
use crate::{flake8_errmsg, settings};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn defaults() -> Result<()> {
|
fn defaults() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// EM101, EM102, EM103
|
/// EM101, EM102, EM103
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Constant, Expr, ExprKind, Location, Operator};
|
||||||
use rustpython_parser::lexer::{LexResult, Tok};
|
use rustpython_parser::lexer::{LexResult, Tok};
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::ISC001, Path::new("ISC.py"); "ISC001")]
|
#[test_case(CheckCode::ISC001, Path::new("ISC.py"); "ISC001")]
|
||||||
#[test_case(CheckCode::ISC002, Path::new("ISC.py"); "ISC002")]
|
#[test_case(CheckCode::ISC002, Path::new("ISC.py"); "ISC002")]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustc_hash::FxHashMap;
|
||||||
use rustpython_ast::Stmt;
|
use rustpython_ast::Stmt;
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// ICN001
|
/// ICN001
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_import_conventions, violations, Settings};
|
use crate::{flake8_import_conventions, Settings};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn defaults() -> Result<()> {
|
fn defaults() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::PIE790, Path::new("PIE790.py"); "PIE790")]
|
#[test_case(CheckCode::PIE790, Path::new("PIE790.py"); "PIE790")]
|
||||||
#[test_case(CheckCode::PIE794, Path::new("PIE794.py"); "PIE794")]
|
#[test_case(CheckCode::PIE794, Path::new("PIE794.py"); "PIE794")]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::types::Range;
|
||||||
use crate::autofix::helpers::delete_stmt;
|
use crate::autofix::helpers::delete_stmt;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// PIE790
|
/// PIE790
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::T201, Path::new("T201.py"); "T201")]
|
#[test_case(CheckCode::T201, Path::new("T201.py"); "T201")]
|
||||||
#[test_case(CheckCode::T203, Path::new("T203.py"); "T203")]
|
#[test_case(CheckCode::T203, Path::new("T203.py"); "T203")]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::ast::helpers::{collect_call_paths, dealias_call_path, is_const_none,
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::helpers;
|
use crate::autofix::helpers;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// T201, T203
|
/// T201, T203
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ mod tests {
|
||||||
use crate::flake8_pytest_style::types;
|
use crate::flake8_pytest_style::types;
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::PT001, Path::new("PT001.py"), Settings::default(), "PT001_default"; "PT001_0")]
|
#[test_case(CheckCode::PT001, Path::new("PT001.py"), Settings::default(), "PT001_default"; "PT001_0")]
|
||||||
#[test_case(
|
#[test_case(
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::ast::visitor;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// Visitor that tracks assert statements and checks if they reference
|
/// Visitor that tracks assert statements and checks if they reference
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use super::helpers::{is_empty_or_null_string, is_pytest_fail};
|
||||||
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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
pub fn fail_call(checker: &mut Checker, call: &Expr, args: &[Expr], keywords: &[Keyword]) {
|
pub fn fail_call(checker: &mut Checker, call: &Expr, args: &[Expr], keywords: &[Keyword]) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::ast::visitor;
|
||||||
use crate::ast::visitor::Visitor;
|
use crate::ast::visitor::Visitor;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use rustpython_ast::Stmt;
|
use rustpython_ast::Stmt;
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_pytest_or_subpackage(imported_name: &str) -> bool {
|
fn is_pytest_or_subpackage(imported_name: &str) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use super::helpers::{get_mark_decorators, get_mark_name};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn pytest_mark_parentheses(
|
fn pytest_mark_parentheses(
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::flake8_pytest_style::types;
|
use crate::flake8_pytest_style::types;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::ast::helpers::{collect_arg_names, compose_call_path, SimpleCallArgs};
|
||||||
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;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
const PATCH_NAMES: &[&str] = &[
|
const PATCH_NAMES: &[&str] = &[
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::ast::helpers::{
|
||||||
};
|
};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_pytest_raises(
|
fn is_pytest_raises(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use rustpython_ast::Location;
|
||||||
|
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::flake8_quotes::settings::{Quote, Settings};
|
use crate::flake8_quotes::settings::{Quote, Settings};
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::source_code_locator::SourceCodeLocator;
|
use crate::source_code_locator::SourceCodeLocator;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
use crate::flake8_quotes::settings::Quote;
|
use crate::flake8_quotes::settings::Quote;
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_quotes, violations, Settings};
|
use crate::{flake8_quotes, Settings};
|
||||||
|
|
||||||
#[test_case(Path::new("doubles.py"))]
|
#[test_case(Path::new("doubles.py"))]
|
||||||
#[test_case(Path::new("doubles_escaped.py"))]
|
#[test_case(Path::new("doubles_escaped.py"))]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{violations, Settings};
|
use crate::Settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::RET501, Path::new("RET501.py"); "RET501")]
|
#[test_case(CheckCode::RET501, Path::new("RET501.py"); "RET501")]
|
||||||
#[test_case(CheckCode::RET502, Path::new("RET502.py"); "RET502")]
|
#[test_case(CheckCode::RET502, Path::new("RET502.py"); "RET502")]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::flake8_return::helpers::result_exists;
|
use crate::flake8_return::helpers::result_exists;
|
||||||
use crate::flake8_return::visitor::{ReturnVisitor, Stack};
|
use crate::flake8_return::visitor::{ReturnVisitor, Stack};
|
||||||
use crate::registry::{Branch, CheckCode, CheckKind};
|
use crate::registry::{Branch, CheckCode};
|
||||||
use crate::{violations, Check};
|
use crate::{violations, Check};
|
||||||
|
|
||||||
/// RET501
|
/// RET501
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{settings, violations};
|
use crate::settings;
|
||||||
|
|
||||||
#[test_case(CheckCode::SIM101, Path::new("SIM101.py"); "SIM101")]
|
#[test_case(CheckCode::SIM101, Path::new("SIM101.py"); "SIM101")]
|
||||||
#[test_case(CheckCode::SIM102, Path::new("SIM102.py"); "SIM102")]
|
#[test_case(CheckCode::SIM102, Path::new("SIM102.py"); "SIM102")]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::ast::helpers::{create_expr, unparse_expr};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// Return `true` if two `Expr` instances are equivalent names.
|
/// Return `true` if two `Expr` instances are equivalent names.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::helpers::{create_expr, create_stmt};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::source_code_generator::SourceCodeGenerator;
|
use crate::source_code_generator::SourceCodeGenerator;
|
||||||
use crate::source_code_style::SourceCodeStyleDetector;
|
use crate::source_code_style::SourceCodeStyleDetector;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::ast::helpers::{create_expr, create_stmt, unparse_expr, unparse_stmt};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckCode, CheckKind};
|
use crate::registry::{Check, CheckCode};
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_main_check(expr: &Expr) -> bool {
|
fn is_main_check(expr: &Expr) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// SIM117
|
/// SIM117
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Cmpop, Expr, ExprKind};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// SIM118
|
/// SIM118
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ 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::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn find_return(stmts: &[Stmt]) -> Option<&Stmt> {
|
fn find_return(stmts: &[Stmt]) -> Option<&Stmt> {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::ast::helpers::{create_expr, unparse_expr};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
fn is_exception_check(stmt: &Stmt) -> bool {
|
fn is_exception_check(stmt: &Stmt) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Excepthandler, ExcepthandlerKind, Stmt, StmtKind};
|
||||||
use crate::ast::helpers;
|
use crate::ast::helpers;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// SIM105
|
/// SIM105
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use rustpython_ast::{Cmpop, Expr, ExprKind};
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::autofix::Fix;
|
use crate::autofix::Fix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// SIM300
|
/// SIM300
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::ast::helpers::match_call_path;
|
||||||
use crate::ast::types::Range;
|
use crate::ast::types::Range;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::flake8_tidy_imports::settings::Strictness;
|
use crate::flake8_tidy_imports::settings::Strictness;
|
||||||
use crate::registry::{Check, CheckKind};
|
use crate::registry::Check;
|
||||||
use crate::violations;
|
use crate::violations;
|
||||||
|
|
||||||
/// TID252
|
/// TID252
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ mod tests {
|
||||||
use crate::flake8_tidy_imports::settings::{BannedApi, Strictness};
|
use crate::flake8_tidy_imports::settings::{BannedApi, Strictness};
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_tidy_imports, violations, Settings};
|
use crate::{flake8_tidy_imports, Settings};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ban_parent_imports() -> Result<()> {
|
fn ban_parent_imports() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::linter::test_path;
|
use crate::linter::test_path;
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::{flake8_unused_arguments, settings, violations};
|
use crate::{flake8_unused_arguments, settings};
|
||||||
|
|
||||||
#[test_case(CheckCode::ARG001, Path::new("ARG.py"); "ARG001")]
|
#[test_case(CheckCode::ARG001, Path::new("ARG.py"); "ARG001")]
|
||||||
#[test_case(CheckCode::ARG002, Path::new("ARG.py"); "ARG002")]
|
#[test_case(CheckCode::ARG002, Path::new("ARG.py"); "ARG002")]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ use path_absolutize::{path_dedot, Absolutize};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
||||||
use crate::registry::CheckCode;
|
use crate::registry::CheckCode;
|
||||||
use crate::violations;
|
|
||||||
|
|
||||||
/// Extract the absolute path and basename (as strings) from a Path.
|
/// Extract the absolute path and basename (as strings) from a Path.
|
||||||
pub fn extract_path_names(path: &Path) -> Result<(&str, &str)> {
|
pub fn extract_path_names(path: &Path) -> Result<(&str, &str)> {
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue