mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 18:11:08 +00:00
Track fix isolation in unnecessary-pass
(#7715)
## Summary This wasn't necessary in the past, since we _only_ applied this rule to bodies that contained two statements, one of which was a `pass`. Now that it applies to any `pass` in a block with multiple statements, we can run into situations in which we remove both passes, and so need to apply the fixes in isolation. See: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1741107573.
This commit is contained in:
parent
974262ad2c
commit
253fbb665f
8 changed files with 140 additions and 14 deletions
|
@ -887,11 +887,9 @@ impl<'a> SemanticModel<'a> {
|
|||
.filter(|id| self.nodes[*id].is_statement())
|
||||
}
|
||||
|
||||
/// Return the [`NodeId`] of the current [`Stmt`].
|
||||
pub fn current_statement_id(&self) -> NodeId {
|
||||
self.current_statement_ids()
|
||||
.next()
|
||||
.expect("No current statement")
|
||||
/// Return the [`NodeId`] of the current [`Stmt`], if any.
|
||||
pub fn current_statement_id(&self) -> Option<NodeId> {
|
||||
self.current_statement_ids().next()
|
||||
}
|
||||
|
||||
/// Return the [`NodeId`] of the current [`Stmt`] parent, if any.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue