Skip to content

Commit

Permalink
special raise
Browse files Browse the repository at this point in the history
  • Loading branch information
tibor-reiss committed Apr 17, 2024
1 parent 451a2f9 commit 8704a3f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ pub(crate) fn invalid_index_return(checker: &mut Checker, name: &str, body: &[St
return;
}

let body_without_comments = body
.iter()
.filter(|stmt| !matches!(stmt, Stmt::Expr(expr) if expr.value.is_string_literal_expr()))
.collect::<Vec<_>>();
if body_without_comments.is_empty() {
return;
}
if body_without_comments.len() == 1 && body_without_comments[0].is_raise_stmt() {
return;
}

let returns = {
let mut visitor = ReturnStatementVisitor::default();
visitor.visit_body(body);
Expand Down

0 comments on commit 8704a3f

Please sign in to comment.