mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00
Split checks and plugins into source-related modules (#447)
This commit is contained in:
parent
1f2ccb059a
commit
118a9feec8
49 changed files with 2083 additions and 2048 deletions
29
src/pyupgrade/plugins/useless_object_inheritance.rs
Normal file
29
src/pyupgrade/plugins/useless_object_inheritance.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use rustpython_ast::{Expr, Keyword, Stmt};
|
||||
|
||||
use crate::autofix::{fixer, fixes};
|
||||
use crate::check_ast::Checker;
|
||||
use crate::pyupgrade::checks;
|
||||
|
||||
pub fn useless_object_inheritance(
|
||||
checker: &mut Checker,
|
||||
stmt: &Stmt,
|
||||
name: &str,
|
||||
bases: &[Expr],
|
||||
keywords: &[Keyword],
|
||||
) {
|
||||
let scope = checker.current_scope();
|
||||
if let Some(mut check) = checks::useless_object_inheritance(name, bases, scope) {
|
||||
if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) {
|
||||
if let Some(fix) = fixes::remove_class_def_base(
|
||||
&mut checker.locator,
|
||||
&stmt.location,
|
||||
check.location,
|
||||
bases,
|
||||
keywords,
|
||||
) {
|
||||
check.amend(fix);
|
||||
}
|
||||
}
|
||||
checker.add_check(check);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue