mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-30 23:27:38 +00:00
parent
812df77246
commit
3b36030461
781 changed files with 207 additions and 208 deletions
|
@ -2,19 +2,20 @@ use std::collections::{BTreeSet, HashMap};
|
|||
|
||||
use anyhow::Result;
|
||||
use colored::Colorize;
|
||||
use ruff::flake8_pytest_style::types::{
|
||||
use ruff::registry::RuleCodePrefix;
|
||||
use ruff::rules::flake8_pytest_style::types::{
|
||||
ParametrizeNameType, ParametrizeValuesRowType, ParametrizeValuesType,
|
||||
};
|
||||
use ruff::flake8_quotes::settings::Quote;
|
||||
use ruff::flake8_tidy_imports::settings::Strictness;
|
||||
use ruff::pydocstyle::settings::Convention;
|
||||
use ruff::registry::RuleCodePrefix;
|
||||
use ruff::rules::flake8_quotes::settings::Quote;
|
||||
use ruff::rules::flake8_tidy_imports::settings::Strictness;
|
||||
use ruff::rules::pydocstyle::settings::Convention;
|
||||
use ruff::rules::{
|
||||
flake8_annotations, flake8_bugbear, flake8_errmsg, flake8_pytest_style, flake8_quotes,
|
||||
flake8_tidy_imports, mccabe, pep8_naming, pydocstyle,
|
||||
};
|
||||
use ruff::settings::options::Options;
|
||||
use ruff::settings::pyproject::Pyproject;
|
||||
use ruff::{
|
||||
flake8_annotations, flake8_bugbear, flake8_errmsg, flake8_pytest_style, flake8_quotes,
|
||||
flake8_tidy_imports, mccabe, pep8_naming, pydocstyle, warn_user,
|
||||
};
|
||||
use ruff::warn_user;
|
||||
|
||||
use crate::black::Black;
|
||||
use crate::plugin::Plugin;
|
||||
|
@ -389,11 +390,11 @@ mod tests {
|
|||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use ruff::pydocstyle::settings::Convention;
|
||||
use ruff::registry::RuleCodePrefix;
|
||||
use ruff::rules::pydocstyle::settings::Convention;
|
||||
use ruff::rules::{flake8_quotes, pydocstyle};
|
||||
use ruff::settings::options::Options;
|
||||
use ruff::settings::pyproject::Pyproject;
|
||||
use ruff::{flake8_quotes, pydocstyle};
|
||||
|
||||
use crate::converter::convert;
|
||||
use crate::plugin::Plugin;
|
||||
|
|
|
@ -2,13 +2,14 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use clap::{command, Parser};
|
||||
use regex::Regex;
|
||||
use ruff::fs;
|
||||
use ruff::logging::LogLevel;
|
||||
use ruff::registry::{RuleCode, RuleCodePrefix};
|
||||
use ruff::resolver::ConfigProcessor;
|
||||
use ruff::rules::mccabe;
|
||||
use ruff::settings::types::{
|
||||
FilePattern, PatternPrefixPair, PerFileIgnore, PythonVersion, SerializationFormat,
|
||||
};
|
||||
use ruff::{fs, mccabe};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
|
|
|
@ -29,20 +29,20 @@ use crate::python::future::ALL_FEATURE_NAMES;
|
|||
use crate::python::typing;
|
||||
use crate::python::typing::SubscriptKind;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
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,
|
||||
flake8_errmsg, flake8_implicit_str_concat, flake8_import_conventions, flake8_pie, flake8_print,
|
||||
flake8_pytest_style, flake8_return, flake8_simplify, flake8_tidy_imports,
|
||||
flake8_unused_arguments, mccabe, pandas_vet, pep8_naming, pycodestyle, pydocstyle, pyflakes,
|
||||
pygrep_hooks, pylint, pyupgrade, ruff,
|
||||
};
|
||||
use crate::settings::types::PythonVersion;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
use crate::violations::DeferralKeyword;
|
||||
use crate::visibility::{module_visibility, transition_scope, Modifier, Visibility, VisibleScope};
|
||||
use crate::{
|
||||
autofix, docstrings, flake8_2020, flake8_annotations, flake8_bandit, flake8_blind_except,
|
||||
flake8_boolean_trap, flake8_bugbear, flake8_builtins, flake8_comprehensions, flake8_datetimez,
|
||||
flake8_debugger, flake8_errmsg, flake8_implicit_str_concat, flake8_import_conventions,
|
||||
flake8_pie, flake8_print, flake8_pytest_style, flake8_return, flake8_simplify,
|
||||
flake8_tidy_imports, flake8_unused_arguments, mccabe, noqa, pandas_vet, pep8_naming,
|
||||
pycodestyle, pydocstyle, pyflakes, pygrep_hooks, pylint, pyupgrade, ruff, violations,
|
||||
visibility,
|
||||
};
|
||||
use crate::{autofix, docstrings, noqa, violations, visibility};
|
||||
|
||||
const GLOBAL_SCOPE_INDEX: usize = 0;
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ use rustpython_parser::ast::Suite;
|
|||
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::directives::IsortDirectives;
|
||||
use crate::isort;
|
||||
use crate::isort::track::{Block, ImportTracker};
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::rules::isort;
|
||||
use crate::rules::isort::track::{Block, ImportTracker};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
//! Lint rules based on checking raw physical lines.
|
||||
|
||||
use crate::pycodestyle::rules::{doc_line_too_long, line_too_long, no_newline_at_end_of_file};
|
||||
use crate::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore};
|
||||
use crate::pyupgrade::rules::unnecessary_coding_comment;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::rules::pycodestyle::rules::{
|
||||
doc_line_too_long, line_too_long, no_newline_at_end_of_file,
|
||||
};
|
||||
use crate::rules::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore};
|
||||
use crate::rules::pyupgrade::rules::unnecessary_coding_comment;
|
||||
use crate::settings::{flags, Settings};
|
||||
|
||||
pub fn check_lines(
|
||||
|
|
|
@ -4,10 +4,10 @@ use rustpython_parser::lexer::{LexResult, Tok};
|
|||
|
||||
use crate::lex::docstring_detection::StateMachine;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::ruff::rules::Context;
|
||||
use crate::rules::ruff::rules::Context;
|
||||
use crate::rules::{eradicate, flake8_implicit_str_concat, flake8_quotes, pycodestyle, ruff};
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::Locator;
|
||||
use crate::{eradicate, flake8_implicit_str_concat, flake8_quotes, pycodestyle, ruff};
|
||||
|
||||
pub fn check_tokens(
|
||||
locator: &Locator,
|
||||
|
|
34
src/lib.rs
34
src/lib.rs
|
@ -28,49 +28,17 @@ mod cst;
|
|||
pub mod directives;
|
||||
mod doc_lines;
|
||||
mod docstrings;
|
||||
mod eradicate;
|
||||
pub mod fix;
|
||||
mod flake8_2020;
|
||||
pub mod flake8_annotations;
|
||||
pub mod flake8_bandit;
|
||||
mod flake8_blind_except;
|
||||
pub mod flake8_boolean_trap;
|
||||
pub mod flake8_bugbear;
|
||||
mod flake8_builtins;
|
||||
mod flake8_comprehensions;
|
||||
mod flake8_datetimez;
|
||||
mod flake8_debugger;
|
||||
pub mod flake8_errmsg;
|
||||
mod flake8_implicit_str_concat;
|
||||
mod flake8_import_conventions;
|
||||
pub mod flake8_pie;
|
||||
mod flake8_print;
|
||||
pub mod flake8_pytest_style;
|
||||
pub mod flake8_quotes;
|
||||
mod flake8_return;
|
||||
mod flake8_simplify;
|
||||
pub mod flake8_tidy_imports;
|
||||
mod flake8_unused_arguments;
|
||||
pub mod fs;
|
||||
mod isort;
|
||||
mod lex;
|
||||
pub mod linter;
|
||||
pub mod logging;
|
||||
pub mod mccabe;
|
||||
pub mod message;
|
||||
mod noqa;
|
||||
mod pandas_vet;
|
||||
pub mod pep8_naming;
|
||||
mod pycodestyle;
|
||||
pub mod pydocstyle;
|
||||
mod pyflakes;
|
||||
mod pygrep_hooks;
|
||||
mod pylint;
|
||||
mod python;
|
||||
mod pyupgrade;
|
||||
pub mod registry;
|
||||
pub mod resolver;
|
||||
mod ruff;
|
||||
pub mod rules;
|
||||
pub mod rustpython_helpers;
|
||||
pub mod settings;
|
||||
pub mod source_code;
|
||||
|
|
|
@ -5,19 +5,20 @@ use rustpython_parser::lexer::LexResult;
|
|||
use serde::Serialize;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::directives;
|
||||
use crate::linter::check_path;
|
||||
use crate::registry::{RuleCode, RuleCodePrefix};
|
||||
use crate::rules::{
|
||||
flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg, flake8_import_conventions,
|
||||
flake8_pytest_style, flake8_quotes, flake8_tidy_imports, flake8_unused_arguments, isort,
|
||||
mccabe, pep8_naming, pycodestyle, pydocstyle, pyupgrade,
|
||||
};
|
||||
use crate::rustpython_helpers::tokenize;
|
||||
use crate::settings::configuration::Configuration;
|
||||
use crate::settings::options::Options;
|
||||
use crate::settings::types::PythonVersion;
|
||||
use crate::settings::{flags, Settings};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
use crate::{
|
||||
directives, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg,
|
||||
flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_tidy_imports,
|
||||
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyupgrade,
|
||||
};
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ fn multiline_case(line: &str) -> bool {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::eradicate::detection::comment_contains_code;
|
||||
use super::comment_contains_code;
|
||||
|
||||
#[test]
|
||||
fn comment_contains_code_basic() {
|
|
@ -1,7 +1,7 @@
|
|||
use rustpython_ast::Location;
|
||||
|
||||
use super::detection::comment_contains_code;
|
||||
use crate::ast::types::Range;
|
||||
use crate::eradicate::detection::comment_contains_code;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::settings::{flags, Settings};
|
|
@ -9,7 +9,6 @@ mod tests {
|
|||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::flake8_annotations;
|
||||
use crate::linter::test_path;
|
||||
use crate::registry::RuleCode;
|
||||
use crate::settings::Settings;
|
||||
|
@ -43,7 +42,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_annotations/suppress_dummy_args.py"),
|
||||
&Settings {
|
||||
flake8_annotations: flake8_annotations::settings::Settings {
|
||||
flake8_annotations: super::settings::Settings {
|
||||
mypy_init_return: false,
|
||||
suppress_dummy_args: true,
|
||||
suppress_none_returning: false,
|
||||
|
@ -67,7 +66,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_annotations/mypy_init_return.py"),
|
||||
&Settings {
|
||||
flake8_annotations: flake8_annotations::settings::Settings {
|
||||
flake8_annotations: super::settings::Settings {
|
||||
mypy_init_return: true,
|
||||
suppress_dummy_args: false,
|
||||
suppress_none_returning: false,
|
||||
|
@ -91,7 +90,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_annotations/suppress_none_returning.py"),
|
||||
&Settings {
|
||||
flake8_annotations: flake8_annotations::settings::Settings {
|
||||
flake8_annotations: super::settings::Settings {
|
||||
mypy_init_return: false,
|
||||
suppress_dummy_args: false,
|
||||
suppress_none_returning: true,
|
||||
|
@ -115,7 +114,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_annotations/allow_star_arg_any.py"),
|
||||
&Settings {
|
||||
flake8_annotations: flake8_annotations::settings::Settings {
|
||||
flake8_annotations: super::settings::Settings {
|
||||
mypy_init_return: false,
|
||||
suppress_dummy_args: false,
|
||||
suppress_none_returning: false,
|
|
@ -1,13 +1,13 @@
|
|||
use log::error;
|
||||
use rustpython_ast::{Constant, Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use super::fixes;
|
||||
use super::helpers::match_function_def;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::ast::{cast, helpers, visitor};
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||
use crate::flake8_annotations::fixes;
|
||||
use crate::flake8_annotations::helpers::match_function_def;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::visibility::Visibility;
|
||||
use crate::{violations, visibility};
|
|
@ -9,7 +9,6 @@ mod tests {
|
|||
use anyhow::Result;
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::flake8_bandit;
|
||||
use crate::linter::test_path;
|
||||
use crate::registry::RuleCode;
|
||||
use crate::settings::Settings;
|
||||
|
@ -46,7 +45,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_bandit/S108.py"),
|
||||
&Settings {
|
||||
flake8_bandit: flake8_bandit::settings::Settings {
|
||||
flake8_bandit: super::settings::Settings {
|
||||
hardcoded_tmp_directory: vec![
|
||||
"/tmp".to_string(),
|
||||
"/var/tmp".to_string(),
|
|
@ -1,7 +1,7 @@
|
|||
use rustpython_ast::{ArgData, Arguments, Expr, Located};
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violations;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use rustpython_ast::Keyword;
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violations;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use rustpython_ast::{Constant, Expr, ExprKind};
|
||||
|
||||
use super::super::helpers::{matches_password_name, string_literal};
|
||||
use crate::ast::types::Range;
|
||||
use crate::flake8_bandit::helpers::{matches_password_name, string_literal};
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violations;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use rustpython_ast::{Constant, Expr, ExprKind, Keyword};
|
||||
|
||||
use super::super::helpers::string_literal;
|
||||
use crate::ast::helpers::SimpleCallArgs;
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::flake8_bandit::helpers::string_literal;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violations;
|
||||
|
|
@ -8,7 +8,6 @@ mod tests {
|
|||
use anyhow::Result;
|
||||
use test_case::test_case;
|
||||
|
||||
use crate::flake8_bugbear;
|
||||
use crate::linter::test_path;
|
||||
use crate::registry::RuleCode;
|
||||
use crate::settings::Settings;
|
||||
|
@ -59,7 +58,7 @@ mod tests {
|
|||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_bugbear/B008_extended.py"),
|
||||
&Settings {
|
||||
flake8_bugbear: flake8_bugbear::settings::Settings {
|
||||
flake8_bugbear: super::settings::Settings {
|
||||
extend_immutable_calls: vec![
|
||||
"fastapi.Depends".to_string(),
|
||||
"fastapi.Query".to_string(),
|
|
@ -1,11 +1,11 @@
|
|||
use rustpython_ast::{Arguments, Constant, Expr, ExprKind};
|
||||
|
||||
use super::mutable_argument_default::is_mutable_func;
|
||||
use crate::ast::helpers::{compose_call_path, to_call_path};
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::flake8_bugbear::rules::mutable_argument_default::is_mutable_func;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violations;
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue