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

False negative Pylint Fails to output W0199 on single item tuple #4655

Closed
JasonF-BJSS opened this issue Jul 2, 2021 · 5 comments · Fixed by #7468
Closed

False negative Pylint Fails to output W0199 on single item tuple #4655

JasonF-BJSS opened this issue Jul 2, 2021 · 5 comments · Fixed by #7468
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Good first issue Friendly and approachable by new contributors Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@JasonF-BJSS
Copy link

Steps to reproduce

Given a file a.py:

# pylint: disable=missing-docstring
assert (1 == 2, "r")
assert (1 == 2,)

Current behaviour

Result of pylint a.py:

************* Module a
a.py:2:0: W0199: Assert called on a 2-item-tuple. Did you mean 'assert x,y'? (assert-on-tuple)

Expected behavior

************* Module a
a.py:2:0: W0199: Assert called on a 2-item-tuple. Did you mean 'assert x,y'? (assert-on-tuple)
a.py:3:0: W0199: Assert called on a 2-item-tuple. Did you mean 'assert x,y'? (assert-on-tuple)

pylint --version output

Result of pylint --version output:

pylint 2.6.2
astroid 2.4.2
Python 3.8.7 (v3.8.7:6503f05dd5, Dec 21 2020, 12:45:15) 
[Clang 6.0 (clang-600.0.57)]
@JasonF-BJSS JasonF-BJSS changed the title Pylint Fails to output W0199 on single item tuple False negative Pylint Fails to output W0199 on single item tuple Jul 2, 2021
@cdce8p cdce8p added False Positive 🦟 A message is emitted but nothing is wrong with the code False Negative 🦋 No message is emitted but something is wrong with the code and removed False Positive 🦟 A message is emitted but nothing is wrong with the code labels Jul 2, 2021
@yushao2
Copy link
Contributor

yushao2 commented Jul 3, 2021

@cdce8p, this seems to be expected behavior from the already implemented functional test:

https://github.com/PyCQA/pylint/blob/main/tests/functional/a/assert_on_tuple.py#L8

@cdce8p
Copy link
Member

cdce8p commented Jul 4, 2021

@cdce8p, this seems to be expected behavior from the already implemented functional test:

Indeed, thanks for the lookup! I didn't look at it closely when adding the tag.
Just the question if it should change then otherwise this issue could be closed.

@cdce8p cdce8p removed the False Negative 🦋 No message is emitted but something is wrong with the code label Jul 4, 2021
@Pierre-Sassoulas
Copy link
Member

What is the legitimate use case of assert (1 == 2,) ?

@JasonF-BJSS
Copy link
Author

JasonF-BJSS commented Jul 5, 2021

There is no legitimate use case I could ever see for assert (1 == 2,), the linter should warn as per assert (1 == 2, "r").

The compiler warns on this in console:

assert (1 == 2,)
:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?

@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jul 2, 2022
@Pierre-Sassoulas
Copy link
Member

It's minor as like @JasonF-BJSS said, python itself is raising a warning, so it will be caught when the code is run but pylint needs to warn beforehand. So the functional tests are wrong, we need to remove them and raise a warning.

@Pierre-Sassoulas Pierre-Sassoulas added Help wanted 🙏 Outside help would be appreciated, good for new contributors Minor 💅 Polishing pylint is always nice Good first issue Friendly and approachable by new contributors labels Jul 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.0 milestone Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Good first issue Friendly and approachable by new contributors Hacktoberfest Help wanted 🙏 Outside help would be appreciated, good for new contributors Minor 💅 Polishing pylint is always nice 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.

4 participants