summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-01-09 15:38:28 +0200
committercpopa <devnull@localhost>2014-01-09 15:38:28 +0200
commit558da6531006902e446b30d4f2b7dbddad768ef3 (patch)
treeb3d1349fdd72ae17de139109c86f96b3a2cfb3cc
parent083eea1072f926ab1c34a8f7b08d8f587dab839e (diff)
downloadpylint-558da6531006902e446b30d4f2b7dbddad768ef3.tar.gz
Ignore non-inferable nodes, add test case for non-inferable nodes.
-rw-r--r--checkers/base.py2
-rw-r--r--test/input/func_bad_reversed_sequence.py7
-rw-r--r--test/messages/func_bad_reversed_sequence.txt14
3 files changed, 16 insertions, 7 deletions
diff --git a/checkers/base.py b/checkers/base.py
index 5df0477..cf4304c 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -711,6 +711,8 @@ functions, methods
except NoSuchArgumentError:
self.add_message('missing-reversed-argument', node=node)
else:
+ if argument is astroid.YES:
+ return
if argument is None:
# nothing was infered
# try to see if we have iter()
diff --git a/test/input/func_bad_reversed_sequence.py b/test/input/func_bad_reversed_sequence.py
index 31c59c0..a394e53 100644
--- a/test/input/func_bad_reversed_sequence.py
+++ b/test/input/func_bad_reversed_sequence.py
@@ -31,6 +31,12 @@ class SecondBadReversed(object):
class ThirdBadReversed(dict):
""" dict subclass """
+def uninferable(seq):
+ """ This can't be infered at this moment,
+ make sure we don't have a false positive.
+ """
+ return reversed(seq)
+
def test():
""" test function """
seq = reversed()
@@ -49,4 +55,5 @@ def test():
seq = reversed(lambda: None)
seq = reversed(deque([]))
seq = reversed("123")
+ seq = uninferable([1, 2, 3])
return seq
diff --git a/test/messages/func_bad_reversed_sequence.txt b/test/messages/func_bad_reversed_sequence.txt
index 712cff2..6e85197 100644
--- a/test/messages/func_bad_reversed_sequence.txt
+++ b/test/messages/func_bad_reversed_sequence.txt
@@ -1,9 +1,9 @@
-E: 36:test: Missing argument to reversed()
-E: 37:test: The first reversed() argument is not a sequence
-E: 40:test: The first reversed() argument is not a sequence
-E: 41:test: The first reversed() argument is not a sequence
-E: 42:test: The first reversed() argument is not a sequence
-E: 45:test: The first reversed() argument is not a sequence
+E: 42:test: Missing argument to reversed()
+E: 43:test: The first reversed() argument is not a sequence
E: 46:test: The first reversed() argument is not a sequence
+E: 47:test: The first reversed() argument is not a sequence
E: 48:test: The first reversed() argument is not a sequence
-E: 49:test: The first reversed() argument is not a sequence \ No newline at end of file
+E: 51:test: The first reversed() argument is not a sequence
+E: 52:test: The first reversed() argument is not a sequence
+E: 54:test: The first reversed() argument is not a sequence
+E: 55:test: The first reversed() argument is not a sequence \ No newline at end of file