diff options
author | cpopa <devnull@localhost> | 2013-07-24 12:19:08 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2013-07-24 12:19:08 +0300 |
commit | f85d38879c0cf2d5f11777cab01392c680d511a7 (patch) | |
tree | 1b98a886deb07f51961c379994843204c339da4b /checkers/variables.py | |
parent | 0ba81f07ea457fd1d3dd0196586358337026b66c (diff) | |
download | pylint-f85d38879c0cf2d5f11777cab01392c680d511a7.tar.gz |
Infer the value before using it, accept astroid.List as well.
Diffstat (limited to 'checkers/variables.py')
-rw-r--r-- | checkers/variables.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/checkers/variables.py b/checkers/variables.py index 02ed3df..2517b0c 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -545,13 +545,18 @@ builtins. Remember that you should avoid to define new builtins when possible.' @check_messages('unbalanced-tuple-unpacking') def visit_assign(self, node): """ Check unbalanced tuple unpacking for assignments. """ - if not isinstance(node.value, astroid.Tuple): + try: + infered = next(node.value.infer()) + except astroid.InferenceError: return - if not isinstance(node.targets[0], astroid.Tuple): + + if not isinstance(infered, (astroid.Tuple, astroid.List)): + return + if not isinstance(node.targets[0], (astroid.Tuple, astroid.List)): return targets = node.targets[0].itered() - values = node.value.itered() + values = infered.itered() if any(not isinstance(target_node, astroid.AssName) for target_node in targets): |