From 8d39f93fa8fca2c0d7d4e90e639aa3d5b5cd88b4 Mon Sep 17 00:00:00 2001 From: harupy Date: Sat, 28 Oct 2023 12:48:10 +0900 Subject: [PATCH 1/3] Improve B015 message --- .../src/rules/flake8_bugbear/rules/useless_comparison.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs index 5b41054e4a899..e0b0a0dab220a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs @@ -32,7 +32,7 @@ impl Violation for UselessComparison { #[derive_message_formats] fn message(&self) -> String { format!( - "Pointless comparison. This comparison does nothing but waste CPU instructions. \ + "Pointless comparison. This comparison does nothing. Did you mean to assign a value? \ Either prepend `assert` or remove it." ) } From 3af27ddac878de630dfe2fe442356b3e929c529d Mon Sep 17 00:00:00 2001 From: harupy Date: Sat, 28 Oct 2023 12:50:09 +0900 Subject: [PATCH 2/3] Update snapshot --- ...inter__rules__flake8_bugbear__tests__B015_B015.py.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap index 46702e5a58a66..cfb586e33ef71 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B015.py:3:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. +B015.py:3:1: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. | 1 | assert 1 == 1 2 | @@ -11,7 +11,7 @@ B015.py:3:1: B015 Pointless comparison. This comparison does nothing but waste C 5 | assert 1 in (1, 2) | -B015.py:7:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. +B015.py:7:1: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. | 5 | assert 1 in (1, 2) 6 | @@ -19,7 +19,7 @@ B015.py:7:1: B015 Pointless comparison. This comparison does nothing but waste C | ^^^^^^^^^^^ B015 | -B015.py:17:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. +B015.py:17:5: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. | 15 | assert 1 in (1, 2) 16 | @@ -27,7 +27,7 @@ B015.py:17:5: B015 Pointless comparison. This comparison does nothing but waste | ^^^^^^^^^^^ B015 | -B015.py:24:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. +B015.py:24:5: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. | 23 | class TestClass: 24 | 1 == 1 From 5ea0316493c30a7912cf9f4b034538b3bdadf9c6 Mon Sep 17 00:00:00 2001 From: harupy Date: Sat, 28 Oct 2023 16:11:32 +0900 Subject: [PATCH 3/3] Address comments --- .../src/rules/flake8_bugbear/rules/useless_comparison.rs | 4 ++-- ...inter__rules__flake8_bugbear__tests__B015_B015.py.snap | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs index e0b0a0dab220a..d5f62107d46e0 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs @@ -32,8 +32,8 @@ impl Violation for UselessComparison { #[derive_message_formats] fn message(&self) -> String { format!( - "Pointless comparison. This comparison does nothing. Did you mean to assign a value? \ - Either prepend `assert` or remove it." + "Pointless comparison. Did you mean to assign a value? \ + Otherwise, prepend `assert` or remove it." ) } } diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap index cfb586e33ef71..a59d23cb43b92 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B015.py:3:1: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. +B015.py:3:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 1 | assert 1 == 1 2 | @@ -11,7 +11,7 @@ B015.py:3:1: B015 Pointless comparison. This comparison does nothing. Did you me 5 | assert 1 in (1, 2) | -B015.py:7:1: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. +B015.py:7:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 5 | assert 1 in (1, 2) 6 | @@ -19,7 +19,7 @@ B015.py:7:1: B015 Pointless comparison. This comparison does nothing. Did you me | ^^^^^^^^^^^ B015 | -B015.py:17:5: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. +B015.py:17:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 15 | assert 1 in (1, 2) 16 | @@ -27,7 +27,7 @@ B015.py:17:5: B015 Pointless comparison. This comparison does nothing. Did you m | ^^^^^^^^^^^ B015 | -B015.py:24:5: B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Either prepend `assert` or remove it. +B015.py:24:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 23 | class TestClass: 24 | 1 == 1