Skip to content

Commit e507a4d

Browse files
Fix a false positive for bad-dunder-name when there is a user-defined __index__ method. (#8619) (#8622)
Closes #8613 (cherry picked from commit f223c6d) Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com>
1 parent 389e14c commit e507a4d

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a false positive for ``bad-dunder-name`` when there is a user-defined ``__index__`` method.
2+
3+
Closes #8613

pylint/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def _get_pylint_home() -> str:
281281
"__getnewargs_ex__",
282282
"__getnewargs__",
283283
"__getstate__",
284+
"__index__",
284285
"__setstate__",
285286
"__reduce__",
286287
"__reduce_ex__",

tests/functional/ext/bad_dunder/bad_dunder_name.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def __private_method(self):
4949
def __doc__(self):
5050
return "Docstring"
5151

52+
def __index__(self):
53+
return 1
54+
5255

5356
def __increase_me__(val):
5457
return val + 1

0 commit comments

Comments
 (0)