From aa90a425e014ebd4f3500c7dc00effa95f5117e9 Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Sat, 28 Oct 2023 20:18:02 +0900 Subject: [PATCH] Improve B015 message (#8295) --- .../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 5b41054e4a..d5f62107d4 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 but waste CPU instructions. \ - 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 46702e5a58..a59d23cb43 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. 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 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. 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 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. 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 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. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. | 23 | class TestClass: 24 | 1 == 1