summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-09-17 10:22:52 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-09-17 10:32:00 +0200
commit1e1c8cfbd2d2420020d5a167b8640169df68fba1 (patch)
treeca6fe1305ce41875a9cfdff62a41bf2ceb173756
parent0a90b4a0b369d75a3e2aee9a4ad57ce264bc18a0 (diff)
downloadpylint-git-1e1c8cfbd2d2420020d5a167b8640169df68fba1.tar.gz
Protect against the redefinition not being found
-rw-r--r--pylint/checkers/base.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 2a1e90497..9f4b8d053 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -842,14 +842,19 @@ class BasicErrorChecker(_BasicChecker):
return
# Check if we have forward references for this node.
- for redefinition in redefinitions[: redefinitions.index(node)]:
- inferred = utils.safe_infer(redefinition)
- if (
- inferred
- and isinstance(inferred, astroid.Instance)
- and inferred.qname() == TYPING_FORWARD_REF_QNAME
- ):
- return
+ try:
+ redefinition_index = redefinitions.index(node)
+ except ValueError:
+ pass
+ else:
+ for redefinition in redefinitions[:redefinition_index]:
+ inferred = utils.safe_infer(redefinition)
+ if (
+ inferred
+ and isinstance(inferred, astroid.Instance)
+ and inferred.qname() == TYPING_FORWARD_REF_QNAME
+ ):
+ return
dummy_variables_rgx = lint_utils.get_global_option(
self, "dummy-variables-rgx", default=None