From a7619d8b15cab95232eb445c104f8d2af48247e7 Mon Sep 17 00:00:00 2001 From: Evan Rittenhouse Date: Wed, 21 Jun 2023 08:14:24 -0500 Subject: [PATCH 1/2] Add Applicability to pandas_vet --- crates/ruff/src/rules/pandas_vet/fixes.rs | 3 +-- ...ruff__rules__pandas_vet__tests__PD002_PD002.py.snap | 10 +++++----- .../ruff__rules__pandas_vet__tests__PD002_fail.snap | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/ruff/src/rules/pandas_vet/fixes.rs b/crates/ruff/src/rules/pandas_vet/fixes.rs index 23ac1a5c3ea91..5f3228cbce461 100644 --- a/crates/ruff/src/rules/pandas_vet/fixes.rs +++ b/crates/ruff/src/rules/pandas_vet/fixes.rs @@ -40,6 +40,5 @@ pub(super) fn convert_inplace_argument_to_assignment( false, ) .ok()?; - #[allow(deprecated)] - Some(Fix::unspecified_edits(insert_assignment, [remove_argument])) + Some(Fix::manual_edits(insert_assignment, [remove_argument])) } diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap index b837655f46ccb..2aaa31b7c9167 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -12,7 +12,7 @@ PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 2 2 | 3 3 | x = pd.DataFrame() 4 4 | @@ -33,7 +33,7 @@ PD002.py:7:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 4 4 | 5 5 | x.drop(["a"], axis=1, inplace=True) 6 6 | @@ -53,7 +53,7 @@ PD002.py:10:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 6 6 | 7 7 | x.drop(["a"], axis=1, inplace=True) 8 8 | @@ -75,7 +75,7 @@ PD002.py:17:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 13 13 | ) 14 14 | 15 15 | if True: @@ -97,7 +97,7 @@ PD002.py:22:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 19 19 | axis=1, 20 20 | ) 21 21 | diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap index 0a60b7ba2d747..fdd4f0677e9f7 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap @@ -10,7 +10,7 @@ source: crates/ruff/src/rules/pandas_vet/mod.rs | = help: Assign to variable; remove `inplace` arg -ℹ Suggested fix +ℹ Possible fix 1 1 | 2 2 | import pandas as pd 3 3 | x = pd.DataFrame() From 4a53879d645fa2e8a2a374b3953f3476a4e2683f Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Jun 2023 12:59:44 -0400 Subject: [PATCH 2/2] Suggested --- crates/ruff/src/rules/pandas_vet/fixes.rs | 2 +- ...ruff__rules__pandas_vet__tests__PD002_PD002.py.snap | 10 +++++----- .../ruff__rules__pandas_vet__tests__PD002_fail.snap | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ruff/src/rules/pandas_vet/fixes.rs b/crates/ruff/src/rules/pandas_vet/fixes.rs index 5f3228cbce461..8a3d368f07b4b 100644 --- a/crates/ruff/src/rules/pandas_vet/fixes.rs +++ b/crates/ruff/src/rules/pandas_vet/fixes.rs @@ -40,5 +40,5 @@ pub(super) fn convert_inplace_argument_to_assignment( false, ) .ok()?; - Some(Fix::manual_edits(insert_assignment, [remove_argument])) + Some(Fix::suggested_edits(insert_assignment, [remove_argument])) } diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap index 2aaa31b7c9167..b837655f46ccb 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -12,7 +12,7 @@ PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 2 2 | 3 3 | x = pd.DataFrame() 4 4 | @@ -33,7 +33,7 @@ PD002.py:7:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 4 4 | 5 5 | x.drop(["a"], axis=1, inplace=True) 6 6 | @@ -53,7 +53,7 @@ PD002.py:10:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 6 6 | 7 7 | x.drop(["a"], axis=1, inplace=True) 8 8 | @@ -75,7 +75,7 @@ PD002.py:17:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent b | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 13 13 | ) 14 14 | 15 15 | if True: @@ -97,7 +97,7 @@ PD002.py:22:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 19 19 | axis=1, 20 20 | ) 21 21 | diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap index fdd4f0677e9f7..0a60b7ba2d747 100644 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap +++ b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap @@ -10,7 +10,7 @@ source: crates/ruff/src/rules/pandas_vet/mod.rs | = help: Assign to variable; remove `inplace` arg -ℹ Possible fix +ℹ Suggested fix 1 1 | 2 2 | import pandas as pd 3 3 | x = pd.DataFrame()