Document comment policy around fix safety (#14300)

## Summary

Closes https://github.com/astral-sh/ruff/issues/9790.
This commit is contained in:
Charlie Marsh 2024-11-13 08:03:58 -05:00 committed by GitHub
parent 89aa804b2d
commit 95c8f5fd0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -11,15 +11,21 @@ use crate::edit::Edit;
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum Applicability {
/// The fix is unsafe and should only be displayed for manual application by the user.
///
/// The fix is likely to be incorrect or the resulting code may have invalid syntax.
DisplayOnly,
/// The fix is unsafe and should only be applied with user opt-in.
/// The fix may be what the user intended, but it is uncertain; the resulting code will have valid syntax.
///
/// The fix may be what the user intended, but it is uncertain. The resulting code will have
/// valid syntax, but may lead to a change in runtime behavior, the removal of user comments,
/// or both.
Unsafe,
/// The fix is safe and can always be applied.
/// The fix is definitely what the user intended, or it maintains the exact meaning of the code.
///
/// The fix is definitely what the user intended, or maintains the exact meaning of the code.
/// User comments are preserved, unless the fix removes an entire statement or expression.
Safe,
}