summaryrefslogtreecommitdiff
path: root/pylint/checkers/variables.py
diff options
context:
space:
mode:
authorDmitry Pribysh <dmand@yandex.ru>2015-11-09 18:16:14 +0300
committerDmitry Pribysh <dmand@yandex.ru>2015-11-09 18:16:14 +0300
commit928d8b8c9ed8f1d6d2e7cfe5d252c6cde47cff7e (patch)
treecc83e1e606edf52173a1c7caa83500633cc1a33c /pylint/checkers/variables.py
parent55c4e267c454e54958aa1de605f3b55f1b6effe7 (diff)
downloadpylint-928d8b8c9ed8f1d6d2e7cfe5d252c6cde47cff7e.tar.gz
Use safe inference in unpacking-non-sequence checker
Unfortunately, this fix means that we won't be able to emit an error for cases like this one: ``` def foo(): if True: return [1, 2] return [3, 4, 5] a, b = foo() ``` Well, not unless we get flow-sensitive inference. But we still need this fix to reduce the number of false-positive errors. Fixes issue #695.
Diffstat (limited to 'pylint/checkers/variables.py')
-rw-r--r--pylint/checkers/variables.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 6f0f5a3..d813e1f 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -21,6 +21,7 @@ import re
from copy import copy
import astroid
+from astroid import helpers
from astroid import modutils
from pylint.interfaces import IAstroidChecker, INFERENCE, INFERENCE_FAILURE, HIGH
@@ -1033,7 +1034,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
targets = node.targets[0].itered()
try:
- for infered in node.value.infer():
+ infered = helpers.safe_infer(node.value)
+ if infered is not None:
self._check_unpacking(infered, node, targets)
except astroid.InferenceError:
return