Skip to content

pointless comparison hint is frequently very off base #12617

@lolbinarycat

Description

@lolbinarycat

code (playground):

def is_some(n):
    n is not None

here, the user is trying to do an implicit return, but python does not have implicit returns. the hint given is this:

B015: Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.

the chance of someone meaning to write = and instead writing is not is approximately zero. if a pointless comparison appears at the end of a function, it should suggest returning it instead of suggesting assert, and the assignment suggestion should only appear if the operator contains =.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomershelp wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions