Skip to content

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

@inoa-jboliveira

Description

@inoa-jboliveira

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions