mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:51:25 +00:00
Avoid attempting to fix PT018 in multi-statement lines (#6829)
## Summary These fixes will _always_ fail, so we should avoid trying to construct them in the first place. Closes https://github.com/astral-sh/ruff/issues/6812.
This commit is contained in:
parent
9b6e008cf1
commit
847432cacf
13 changed files with 109 additions and 52 deletions
|
@ -60,6 +60,17 @@ impl Diagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the [`Fix`] used to fix the diagnostic, if the provided function returns `Ok`.
|
||||
/// Otherwise, log the error.
|
||||
#[inline]
|
||||
pub fn try_set_optional_fix(&mut self, func: impl FnOnce() -> Result<Option<Fix>>) {
|
||||
match func() {
|
||||
Ok(None) => {}
|
||||
Ok(Some(fix)) => self.fix = Some(fix),
|
||||
Err(err) => error!("Failed to create fix for {}: {}", self.kind.name, err),
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue