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

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

Closed
Pierre-Sassoulas opened this issue Oct 31, 2021 · 0 comments · Fixed by #7354
Closed
Labels
Enhancement ✨ Improvement to a component Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Pierre-Sassoulas
Copy link
Member

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)

@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label Oct 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.0 milestone Apr 14, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Jul 8, 2022
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Aug 25, 2022
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Aug 25, 2022
Pierre-Sassoulas added a commit that referenced this issue Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant