mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
[refurb] Implement repeated-append
rule (FURB113
) (#6702)
## Summary As an initial effort with replicating `refurb` rules (#1348 ), this PR adds support for [FURB113](https://github.com/dosisod/refurb/blob/master/refurb/checks/builtin/list_extend.py) and adds a new category of checks. ## Test Plan I included a new test + checked that all other tests pass.
This commit is contained in:
parent
1439bb592e
commit
26d53c56a2
13 changed files with 1003 additions and 11 deletions
|
@ -3,6 +3,7 @@ use crate::{self as ast, ExceptHandler, Stmt, Suite};
|
|||
|
||||
/// Given a [`Stmt`] and its parent, return the [`Suite`] that contains the [`Stmt`].
|
||||
pub fn suite<'a>(stmt: &'a Stmt, parent: &'a Stmt) -> Option<&'a Suite> {
|
||||
// TODO: refactor this to work without a parent, ie when `stmt` is at the top level
|
||||
match parent {
|
||||
Stmt::FunctionDef(ast::StmtFunctionDef { body, .. }) => Some(body),
|
||||
Stmt::ClassDef(ast::StmtClassDef { body, .. }) => Some(body),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue