Skip to content

Commit f223c6d

Browse files
authored
Fix a false positive for bad-dunder-name when there is a user-defined __index__ method. (#8619)
Closes #8613
1 parent a83137d commit f223c6d

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
@@ -231,6 +231,7 @@ def _get_pylint_home() -> str:
231231
"__getnewargs_ex__",
232232
"__getnewargs__",
233233
"__getstate__",
234+
"__index__",
234235
"__setstate__",
235236
"__reduce__",
236237
"__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)