Split checks and plugins into source-related modules (#447)

This commit is contained in:
Charlie Marsh 2022-10-17 15:38:49 -04:00 committed by GitHub
parent 1f2ccb059a
commit 118a9feec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 2083 additions and 2048 deletions

View file

@ -0,0 +1,27 @@
use rustpython_ast::{Expr, Stmt};
use crate::ast::helpers;
use crate::autofix::{fixer, fixes};
use crate::check_ast::Checker;
use crate::pyupgrade::checks;
pub fn super_call_with_parameters(checker: &mut Checker, expr: &Expr, func: &Expr, args: &[Expr]) {
// Only bother going through the super check at all if we're in a `super` call.
// (We check this in `check_super_args` too, so this is just an optimization.)
if helpers::is_super_call_with_arguments(func, args) {
let scope = checker.current_scope();
let parents: Vec<&Stmt> = checker
.parent_stack
.iter()
.map(|index| checker.parents[*index])
.collect();
if let Some(mut check) = checks::super_args(scope, &parents, expr, func, args) {
if matches!(checker.autofix, fixer::Mode::Generate | fixer::Mode::Apply) {
if let Some(fix) = fixes::remove_super_arguments(&mut checker.locator, expr) {
check.amend(fix);
}
}
checker.add_check(check)
}
}
}