Commits

Georg Brandl committed 4e73450

Add a checker for calling tuples (happens in lists of tuples when forgetting a comma).

Comments (0)

Files changed (2)

pyflakes/checker.py

 
     # "expr" type nodes
     BOOLOP = UNARYOP = LAMBDA = IFEXP = DICT = SET = YIELD = COMPARE = \
-    CALL = REPR = SUBSCRIPT = LIST = TUPLE = handleChildren
+        REPR = SUBSCRIPT = LIST = TUPLE = handleChildren
 
     NUM = STR = ELLIPSIS = ignore
 
             self.handleNode(node.left, node)
             self.handleNode(node.right, node)
 
+    def CALL(self, node):
+        if isinstance(node.func, _ast.Tuple):
+            self.report(messages.TupleCall, node.lineno)
+        self.handleChildren(node)
+
     def ATTRIBUTE(self, node):
         if isinstance(node.value, _ast.Str) and node.attr == 'format' and \
            isinstance(node.parent, _ast.Call) and node is node.parent.func:

pyflakes/messages.py

     def __init__(self, filename, lineno, name):
         Message.__init__(self, filename, lineno)
         self.message_args = (name,)
+
+
+class TupleCall(Message):
+    """
+    Indicates that an Error or Exception is returned instead of raised.
+    """
+
+    message = 'calling tuple literal'
+    def __init__(self, filename, lineno):
+        Message.__init__(self, filename, lineno)