diff options
author | Dmitry Pribysh <dmand@yandex.ru> | 2015-11-07 19:09:00 +0300 |
---|---|---|
committer | Dmitry Pribysh <dmand@yandex.ru> | 2015-11-07 19:09:00 +0300 |
commit | 66c1d7ea3b40b1bb95e46b96f503aca9b23cec64 (patch) | |
tree | c300bd8aa98251d7f41b310eebb35ce8aa23bbcd /pylint/checkers/classes.py | |
parent | cfc0f8a29c36855914d5cb04572796663e4ad627 (diff) | |
download | pylint-git-66c1d7ea3b40b1bb95e46b96f503aca9b23cec64.tar.gz |
Reduce number of false positives emitted by non-iterator-returned checker
By disabling checker for cases when there're multiple possible values infered
for node. This way we lose some of the inference power, but throw a lot less
false positives.
Fixes issue #695.
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r-- | pylint/checkers/classes.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 3d9144d34..24b862fd7 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -1067,12 +1067,15 @@ class SpecialMethodsChecker(BaseChecker): def _check_iter(self, node): try: - infered = node.infer_call_result(node) + infered_values = list(node.infer_call_result(node)) except astroid.InferenceError: return - - if not all(map(self._is_iterator, infered)): - self.add_message('non-iterator-returned', node=node) + # cases when there're multiple values infered + # are skipped to reduce the number of false positives + if len(infered_values) == 1: + infered = infered_values[0] + if not self._is_iterator(infered): + self.add_message('non-iterator-returned', node=node) def _ancestors_to_call(klass_node, method='__init__'): |