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 negatives for consider-using-tuple #8948

Closed
EugeneZelenko opened this issue Aug 12, 2023 · 3 comments
Closed

False negatives for consider-using-tuple #8948

EugeneZelenko opened this issue Aug 12, 2023 · 3 comments
Labels
Invalid Not a bug, already exists or already fixed

Comments

@EugeneZelenko
Copy link

Bug description

Looks like consider-using-tuple does not analyze in/not in operators in conditional statements:

name = 'test'
if name in ['value 1', 'value 2']:
    print('found something')
elif name in ['value 3', 'value 4']:
    print('found another thing')
elif name not in ['value 5', 'value 6']:
    print('passed some filter')

Configuration

No response

Command used

pylint --load-plugins=pylint.extensions.code_style --enable=all test.py

Pylint output

************* Module pylint_test
pylint_test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
pylint_test.py:1:0: C0103: Constant name "name" doesn't conform to UPPER_CASE naming style (invalid-name)

------------------------------------------------------------------
Your code has been rated at 7.14/10 (previous run: 7.14/10, +0.00)

Expected behavior

Warnings should suggest to convert all three lists to tuples.

Pylint version

pylint 2.17.4
astroid 2.15.5
Python 3.11.4 (main, Jun 26 2023, 16:57:25) [GCC 7.5.0]

OS / Environment

No response

Additional dependencies

No response

@EugeneZelenko EugeneZelenko added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 12, 2023
@Pierre-Sassoulas
Copy link
Member

I don't remember everything around it, but it's possible that it's volontary because sets are more adequate for membership tests.

@Pierre-Sassoulas Pierre-Sassoulas added Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 12, 2023
@EugeneZelenko
Copy link
Author

Sure, permanent sets should be better for performance. But is it true for temporary things?

@Pierre-Sassoulas
Copy link
Member

If you launch pylint with pylint test.py --enable=all --enable-all-extentions you would get a suggestion to use set: 2:11: R6201: Consider using set for membership test (use-set-for-membership). See #4776 and attached merge request for full discussion.

@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Invalid Not a bug, already exists or already fixed and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

2 participants