Rename autofix::helpers to autofix::actions (#3866)

This commit is contained in:
Charlie Marsh 2023-04-03 13:34:49 -04:00 committed by GitHub
parent 5625410936
commit 449e08ed08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 21 additions and 20 deletions

View file

@ -1,3 +1,4 @@
//! Interface for generating autofix edits from higher-level actions (e.g., "remove an argument").
use anyhow::{bail, Result};
use itertools::Itertools;
use libcst_native::{
@ -531,7 +532,7 @@ mod tests {
use ruff_python_ast::source_code::Locator;
use crate::autofix::helpers::{next_stmt_break, trailing_semicolon};
use crate::autofix::actions::{next_stmt_break, trailing_semicolon};
#[test]
fn find_semicolon() -> Result<()> {

View file

@ -11,7 +11,7 @@ use ruff_python_ast::types::Range;
use crate::linter::FixTable;
use crate::registry::{AsRule, Rule};
pub mod helpers;
pub mod actions;
/// Auto-fix errors in a file, and write the fixed source code to disk.
pub fn fix_file(diagnostics: &[Diagnostic], locator: &Locator) -> Option<(String, FixTable)> {

View file

@ -5066,7 +5066,7 @@ impl<'a> Checker<'a> {
let fix = if !in_init && !in_except_handler && self.patch(Rule::UnusedImport) {
let deleted: Vec<&Stmt> = self.deletions.iter().map(Into::into).collect();
match autofix::helpers::remove_unused_imports(
match autofix::actions::remove_unused_imports(
unused_imports.iter().map(|(full_name, _)| *full_name),
child,
parent,

View file

@ -16,7 +16,7 @@ use ruff_python_ast::helpers::{any_over_expr, create_expr, match_trailing_commen
use ruff_python_ast::types::{Range, RefEquality};
use ruff_python_stdlib::identifiers::is_identifier;
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use crate::checkers::ast::Checker;
use crate::message::Location;
use crate::registry::AsRule;

View file

@ -1,4 +1,4 @@
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use log::error;
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};

View file

@ -11,7 +11,7 @@ use ruff_python_ast::types::Range;
use ruff_python_ast::visitor;
use ruff_python_ast::visitor::Visitor;
use crate::autofix::helpers::remove_argument;
use crate::autofix::actions::remove_argument;
use crate::checkers::ast::Checker;
use crate::registry::{AsRule, Rule};

View file

@ -5,7 +5,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::{Range, RefEquality};
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -3,7 +3,7 @@ use rustpython_parser::ast::{Expr, ExprKind, Keyword, Location};
use ruff_diagnostics::{Edit, Fix};
use ruff_python_ast::source_code::Locator;
use crate::autofix::helpers::remove_argument;
use crate::autofix::actions::remove_argument;
fn match_name(expr: &Expr) -> Option<&str> {
if let ExprKind::Call { func, .. } = &expr.node {

View file

@ -10,7 +10,7 @@ use ruff_python_ast::scope::{ScopeId, ScopeKind};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::{Range, RefEquality};
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -4,7 +4,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::autofix::helpers::get_or_import_symbol;
use crate::autofix::actions::get_or_import_symbol;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -7,7 +7,7 @@ use ruff_python_ast::helpers::{is_const_none, ReturnStatementVisitor};
use ruff_python_ast::types::{Range, RefEquality};
use ruff_python_ast::visitor::Visitor;
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -4,7 +4,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::autofix::helpers::get_or_import_symbol;
use crate::autofix::actions::get_or_import_symbol;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -11,7 +11,7 @@ use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::{Range, RefEquality};
use ruff_python_ast::whitespace::indentation;
use crate::autofix::helpers::delete_stmt;
use crate::autofix::actions::delete_stmt;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;
use crate::rules::pyupgrade::fixes::adjust_indentation;

View file

@ -7,7 +7,7 @@ use ruff_python_ast::helpers::find_keyword;
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::autofix::helpers::remove_argument;
use crate::autofix::actions::remove_argument;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;

View file

@ -112,7 +112,7 @@ pub fn unnecessary_builtin_import(
.iter()
.map(|alias| format!("{module}.{}", alias.node.name))
.collect();
match autofix::helpers::remove_unused_imports(
match autofix::actions::remove_unused_imports(
unused_imports.iter().map(String::as_str),
defined_by.into(),
defined_in.map(Into::into),

View file

@ -6,7 +6,7 @@ use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::source_code::Locator;
use ruff_python_ast::types::Range;
use crate::autofix::helpers::remove_argument;
use crate::autofix::actions::remove_argument;
use crate::checkers::ast::Checker;
use crate::registry::Rule;

View file

@ -92,7 +92,7 @@ pub fn unnecessary_future_import(checker: &mut Checker, stmt: &Stmt, names: &[Lo
.iter()
.map(|alias| format!("__future__.{}", alias.node.name))
.collect();
match autofix::helpers::remove_unused_imports(
match autofix::actions::remove_unused_imports(
unused_imports.iter().map(String::as_str),
defined_by.into(),
defined_in.map(Into::into),

View file

@ -5,7 +5,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::types::Range;
use crate::autofix::helpers;
use crate::autofix::actions;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;
@ -52,7 +52,7 @@ pub fn useless_metaclass_type(checker: &mut Checker, stmt: &Stmt, value: &Expr,
let deleted: Vec<&Stmt> = checker.deletions.iter().map(Into::into).collect();
let defined_by = checker.ctx.current_stmt();
let defined_in = checker.ctx.current_stmt_parent();
match helpers::delete_stmt(
match actions::delete_stmt(
defined_by.into(),
defined_in.map(Into::into),
&deleted,

View file

@ -6,7 +6,7 @@ use ruff_python_ast::binding::{Binding, BindingKind, Bindings};
use ruff_python_ast::scope::Scope;
use ruff_python_ast::types::Range;
use crate::autofix::helpers::remove_argument;
use crate::autofix::actions::remove_argument;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;