Skip to content
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 message on "useless-comparison" (B015) #8069

Closed
inoa-jboliveira opened this issue Oct 19, 2023 · 2 comments · Fixed by #8295
Closed

Improve message on "useless-comparison" (B015) #8069

inoa-jboliveira opened this issue Oct 19, 2023 · 2 comments · Fixed by #8295
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@inoa-jboliveira
Copy link

inoa-jboliveira commented Oct 19, 2023

ruff version 0.1.0 (and likely any older version)

Currently using B015 we get the following message:

B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.

This message is very unhelpful because no ones writes foo = bar in a line and cares about wasting CPU instructions. It just sounds like this is one of those annoying fixes that won't catch any bugs.

The actual use case for this test should be when someone types == by accident and wanted to type = instead.

like data['success'] == False instead of data['success'] = False

This message should be something in the lines:

B015 Pointless comparison. This comparison does nothing. Did you mean to assign a value? Otherwise prepend `assert` or remove it.
@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label Oct 20, 2023
@charliermarsh
Copy link
Member

Agree, this could be improved.

@zanieb
Copy link
Member

zanieb commented Oct 20, 2023

The existing message does have the befit of being really silly :D

I like your proposal!

@zanieb zanieb added the good first issue Good for newcomers label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants