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

Bad dunder name is flagging __index__ #8613

Closed
Redoubts opened this issue Apr 24, 2023 · 4 comments · Fixed by #8619
Closed

Bad dunder name is flagging __index__ #8613

Redoubts opened this issue Apr 24, 2023 · 4 comments · Fixed by #8619
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Redoubts
Copy link

Bug description

consider

class X:
    def __index__(self):
        return 1

this will flag index as a bad dunder, even though it is valid to do.

Configuration

No response

Command used

pylint x.py

Pylint output

************* Module x
x.py:2:4: W3201: Bad or misspelled dunder method name __index__. (bad-dunder-name)

Expected behavior

no lint

Pylint version

% pylint --version
pylint 2.17.2
astroid 2.15.4
Python 3.10.11 (main, Apr 10 2023, 08:08:57) [GCC 8.3.0]

OS / Environment

No response

Additional dependencies

No response

@Redoubts Redoubts added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 24, 2023
@Redoubts
Copy link
Author

there's an obvious workaround in the config, but I think that shouldn't be needed

@mbyrnepr2
Copy link
Member

Thanks for opening the issue @Redoubts. I believe this has been fixed since Pylint 2.15.5.

Tested on:

pylint --version
pylint 3.0.0b1
astroid 2.16.0dev0
Python 3.10.4

@mbyrnepr2 mbyrnepr2 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Invalid Not a bug, already exists or already fixed and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 24, 2023
@Redoubts
Copy link
Author

Redoubts commented Apr 24, 2023 via email

@mbyrnepr2 mbyrnepr2 reopened this Apr 24, 2023
@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Apr 24, 2023

Sorry @Redoubts! Re-opening. I didn't realise this is an extension. The link I shared was a fix for calling __index__ methods.
Reproducible on main branch with:

pylint example.py --load-plugins=pylint.extensions.dunder

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Invalid Not a bug, already exists or already fixed labels Apr 24, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Apr 24, 2023
@mbyrnepr2 mbyrnepr2 added the Needs PR This issue is accepted, sufficiently specified and now needs an implementation label Apr 24, 2023
@mbyrnepr2 mbyrnepr2 added this to the 2.17.4 milestone Apr 24, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Apr 24, 2023
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Apr 24, 2023
Pierre-Sassoulas pushed a commit that referenced this issue Apr 24, 2023
github-actions bot pushed a commit that referenced this issue Apr 24, 2023
…ined ``__index__`` method. (#8619)

Closes #8613

(cherry picked from commit f223c6d)
Pierre-Sassoulas pushed a commit that referenced this issue Apr 24, 2023
…ined ``__index__`` method. (#8619) (#8622)

Closes #8613

(cherry picked from commit f223c6d)

Co-authored-by: Mark Byrne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code 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.

3 participants