diff --git a/crates/ruff_diagnostics/src/fix.rs b/crates/ruff_diagnostics/src/fix.rs index d44ef411ce039..751258508f718 100644 --- a/crates/ruff_diagnostics/src/fix.rs +++ b/crates/ruff_diagnostics/src/fix.rs @@ -12,7 +12,7 @@ use crate::edit::Edit; 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. - Display, + 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. @@ -87,22 +87,22 @@ impl Fix { } } - /// Create a new [`Fix`] that should only [display](Applicability::Display) and not apply from an [`Edit`] element . - pub fn display_edit(edit: Edit) -> Self { + /// Create a new [`Fix`] that should only [display](Applicability::DisplayOnly) and not apply from an [`Edit`] element . + pub fn display_only_edit(edit: Edit) -> Self { Self { edits: vec![edit], - applicability: Applicability::Display, + applicability: Applicability::DisplayOnly, isolation_level: IsolationLevel::default(), } } - /// Create a new [`Fix`] that should only [display](Applicability::Display) and not apply from multiple [`Edit`] elements. - pub fn display_edits(edit: Edit, rest: impl IntoIterator) -> Self { + /// Create a new [`Fix`] that should only [display](Applicability::DisplayOnly) and not apply from multiple [`Edit`] elements. + pub fn display_only_edits(edit: Edit, rest: impl IntoIterator) -> Self { let mut edits: Vec = std::iter::once(edit).chain(rest).collect(); edits.sort_by_key(|edit| (edit.start(), edit.end())); Self { edits, - applicability: Applicability::Display, + applicability: Applicability::DisplayOnly, isolation_level: IsolationLevel::default(), } } diff --git a/crates/ruff_linter/src/message/diff.rs b/crates/ruff_linter/src/message/diff.rs index 8c9b3e4d62104..2ba3f24ee24df 100644 --- a/crates/ruff_linter/src/message/diff.rs +++ b/crates/ruff_linter/src/message/diff.rs @@ -56,7 +56,7 @@ impl Display for Diff<'_> { // TODO(zanieb): Adjust this messaging once it's user-facing Applicability::Safe => "Safe fix", Applicability::Unsafe => "Unsafe fix", - Applicability::Display => "Display only fix", + Applicability::DisplayOnly => "Display-only fix", }; writeln!(f, "ℹ {}", message.blue())?; diff --git a/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs b/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs index 6dbe63570f10b..fd468a2c23367 100644 --- a/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs +++ b/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs @@ -66,7 +66,7 @@ pub(crate) fn commented_out_code( if is_standalone_comment(line) && comment_contains_code(line, &settings.task_tags[..]) { let mut diagnostic = Diagnostic::new(CommentedOutCode, *range); - diagnostic.set_fix(Fix::display_edit(Edit::range_deletion( + diagnostic.set_fix(Fix::display_only_edit(Edit::range_deletion( locator.full_lines_range(*range), ))); diagnostics.push(diagnostic); diff --git a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap index 42696a246473d..6864796be7573 100644 --- a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap +++ b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap @@ -10,7 +10,7 @@ ERA001.py:1:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 1 |-#import os 2 1 | # from foo import junk 3 2 | #a = 3 @@ -26,7 +26,7 @@ ERA001.py:2:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 1 1 | #import os 2 |-# from foo import junk 3 2 | #a = 3 @@ -44,7 +44,7 @@ ERA001.py:3:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 1 1 | #import os 2 2 | # from foo import junk 3 |-#a = 3 @@ -63,7 +63,7 @@ ERA001.py:5:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 2 2 | # from foo import junk 3 3 | #a = 3 4 4 | a = 4 @@ -82,7 +82,7 @@ ERA001.py:13:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 10 10 | 11 11 | # This is a real comment. 12 12 | # # This is a (nested) comment. @@ -100,7 +100,7 @@ ERA001.py:21:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 18 18 | 19 19 | class A(): 20 20 | pass @@ -120,7 +120,7 @@ ERA001.py:26:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 23 23 | 24 24 | dictionary = { 25 25 | # "key1": 123, # noqa: ERA001 @@ -139,7 +139,7 @@ ERA001.py:27:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 24 24 | dictionary = { 25 25 | # "key1": 123, # noqa: ERA001 26 26 | # "key2": 456, diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs index 39f0f5b5ca735..5c8e2a4d1cfa7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -123,7 +123,7 @@ pub(crate) fn lambda_assignment( .get_all(id) .any(|binding_id| checker.semantic().binding(binding_id).kind.is_annotation()) { - diagnostic.set_fix(Fix::display_edit(Edit::range_replacement( + diagnostic.set_fix(Fix::display_only_edit(Edit::range_replacement( indented, stmt.range(), ))); diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap index edc8036cda857..9711dbafcdd9f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap @@ -109,7 +109,7 @@ E731.py:57:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Display only fix +ℹ Display-only fix 54 54 | 55 55 | class Scope: 56 56 | # E731 @@ -128,7 +128,7 @@ E731.py:64:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `f` as a `def` -ℹ Display only fix +ℹ Display-only fix 61 61 | from typing import Callable 62 62 | 63 63 | # E731 @@ -150,7 +150,7 @@ E731.py:73:9: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `x` as a `def` -ℹ Display only fix +ℹ Display-only fix 70 70 | 71 71 | x: Callable[[int], int] 72 72 | if True: @@ -171,7 +171,7 @@ E731.py:75:9: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `x` as a `def` -ℹ Display only fix +ℹ Display-only fix 72 72 | if True: 73 73 | x = lambda: 1 74 74 | else: @@ -331,7 +331,7 @@ E731.py:139:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `CELSIUS` as a `def` -ℹ Display only fix +ℹ Display-only fix 136 136 | 137 137 | 138 138 | class TemperatureScales(Enum): @@ -351,7 +351,7 @@ E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` | = help: Rewrite `FAHRENHEIT` as a `def` -ℹ Display only fix +ℹ Display-only fix 137 137 | 138 138 | class TemperatureScales(Enum): 139 139 | CELSIUS = (lambda deg_c: deg_c) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap index 1c8a85ef7dac2..a58ef10cb160d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap @@ -11,7 +11,7 @@ RUF100_5.py:7:5: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 4 4 | dictionary = { 5 5 | # "key1": 123, # noqa: ERA001 6 6 | # "key2": 456, # noqa @@ -27,7 +27,7 @@ RUF100_5.py:11:1: ERA001 Found commented-out code | = help: Remove commented-out code -ℹ Display only fix +ℹ Display-only fix 8 8 | } 9 9 | 10 10 |