-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve B015 message #8295
Improve B015 message #8295
Conversation
@@ -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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should now be Otherwise, prepend...
@@ -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? \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd suggest removing "This comparison does nothing.", it feels redundant.
Thanks @harupy! |
PR Check ResultsEcosystemℹ️ ecosystem check detected linter changes. (+67 -67 violations, +0 -0 fixes in 41 projects) apache/airflow (+35 -35 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --select ALL
+ tests/core/test_otel_logger.py:179:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/core/test_otel_logger.py:179:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/core/test_otel_logger.py:198:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/core/test_otel_logger.py:198:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/core/test_otel_logger.py:253:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/core/test_otel_logger.py:253:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/decorators/test_mapped.py:37:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/decorators/test_mapped.py:37:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/decorators/test_mapped.py:38:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/decorators/test_mapped.py:38:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/jobs/test_backfill_job.py:1999:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/jobs/test_backfill_job.py:1999:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/jobs/test_backfill_job.py:2000:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/jobs/test_backfill_job.py:2000:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/jobs/test_backfill_job.py:2001:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/jobs/test_backfill_job.py:2001:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/jobs/test_scheduler_job.py:1906:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/jobs/test_scheduler_job.py:1906:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/jobs/test_scheduler_job.py:3946:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/jobs/test_scheduler_job.py:3946:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/models/test_baseoperator.py:648:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/models/test_baseoperator.py:648:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/models/test_baseoperator.py:656:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/models/test_baseoperator.py:656:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/models/test_baseoperator.py:658:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/models/test_baseoperator.py:658:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. ... 44 additional changes omitted for project bokeh/bokeh (+3 -3 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --select ALL
+ tests/unit/bokeh/document/test_callbacks__document.py:314:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/unit/bokeh/document/test_callbacks__document.py:314:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/unit/bokeh/document/test_callbacks__document.py:317:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/unit/bokeh/document/test_callbacks__document.py:317:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + tests/unit/bokeh/models/test_plots.py:485:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - tests/unit/bokeh/models/test_plots.py:485:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. demisto/content (+29 -29 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero
+ Packs/AzureSecurityCenter/Integrations/MicrosoftDefenderForCloudEventCollector/MicrosoftDefenderForCloudEventCollector_test.py:188:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/AzureSecurityCenter/Integrations/MicrosoftDefenderForCloudEventCollector/MicrosoftDefenderForCloudEventCollector_test.py:188:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:434:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:434:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:503:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:503:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:157:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:157:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:159:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:159:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:165:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:165:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:166:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:166:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:167:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:167:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/CTIX/Integrations/CTIX/CTIX.py:492:17: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/CTIX/Integrations/CTIX/CTIX.py:492:17: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/CTIX/Integrations/CTIX/CTIX.py:520:17: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. - Packs/CTIX/Integrations/CTIX/CTIX.py:520:17: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + Packs/CTIX/Integrations/CTIXv3/CTIXv3.py:808:21: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. ... 37 additional changes omitted for project Changes by rule (1 rules affected)
|
crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs
Outdated
Show resolved
Hide resolved
799d011
to
5ea0316
Compare
Summary
Close #8069
Test Plan
cargo test