summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-04-24 19:50:25 +0000
committerGitHub <noreply@github.com>2023-04-24 19:50:25 +0000
commite507a4d87ec80e706ac0c8ce2d23bd28006cbbbc (patch)
treebb12536fcd04cb94a57c1e832ab632e8862446b8
parent389e14c36819cb87190fd412d3f366a3283f0078 (diff)
downloadpylint-git-e507a4d87ec80e706ac0c8ce2d23bd28006cbbbc.tar.gz
Fix a false positive for ``bad-dunder-name`` when there is a user-defined ``__index__`` method. (#8619) (#8622)
Closes #8613 (cherry picked from commit f223c6de3a39eae6d1c76e30b55da28639dd8777) Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com>
-rw-r--r--doc/whatsnew/fragments/8613.false_positive3
-rw-r--r--pylint/constants.py1
-rw-r--r--tests/functional/ext/bad_dunder/bad_dunder_name.py3
3 files changed, 7 insertions, 0 deletions
diff --git a/doc/whatsnew/fragments/8613.false_positive b/doc/whatsnew/fragments/8613.false_positive
new file mode 100644
index 000000000..80d28e9c2
--- /dev/null
+++ b/doc/whatsnew/fragments/8613.false_positive
@@ -0,0 +1,3 @@
+Fix a false positive for ``bad-dunder-name`` when there is a user-defined ``__index__`` method.
+
+Closes #8613
diff --git a/pylint/constants.py b/pylint/constants.py
index ad7fc2256..de29fb9b8 100644
--- a/pylint/constants.py
+++ b/pylint/constants.py
@@ -281,6 +281,7 @@ EXTRA_DUNDER_METHODS = [
"__getnewargs_ex__",
"__getnewargs__",
"__getstate__",
+ "__index__",
"__setstate__",
"__reduce__",
"__reduce_ex__",
diff --git a/tests/functional/ext/bad_dunder/bad_dunder_name.py b/tests/functional/ext/bad_dunder/bad_dunder_name.py
index 48247aba0..6008866b1 100644
--- a/tests/functional/ext/bad_dunder/bad_dunder_name.py
+++ b/tests/functional/ext/bad_dunder/bad_dunder_name.py
@@ -49,6 +49,9 @@ class Apples:
def __doc__(self):
return "Docstring"
+ def __index__(self):
+ return 1
+
def __increase_me__(val):
return val + 1