Skip to content

R0123 (literal-comparison) message is not explicit about the problem and the solution #5237

@Pierre-Sassoulas

Description

@Pierre-Sassoulas

Current problem

R0123: Comparison to literal (literal-comparison), which I think could be made more explicit. Maybe something like a.py:3:25: R0123: 'val_value is ""' could be replaced by 'val_value' (literal-comparison) (or bool(val_value) if it's not a context where we have an auto-cast to boolean ?)

Desired solution

Flake8 says : F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple). we can also piggy back on the documentation for this flake8 check when pylint users search for the error messages.

Maybe we should include the words "Truth Value Testing" as this is the official wording in the Python docs, and people who want to know more can therefore easily find the page linked above.
'if val_value is ""' could be replaced by 'if val_value' (Truth Value Testing) (literal-comparison)

Additional context

#5234 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions