Attached Documents

bug105298_E1120_patch2.diffclass_init_parameters.pyinstance_call_parameters.py

bug105298_E1120_patch2.diff

download
diff -r a8e0d01488a1 checkers/typecheck.py
--- a/checkers/typecheck.py	Thu Sep 06 10:54:35 2012 +0200
+++ b/checkers/typecheck.py	Mon Sep 17 00:13:59 2012 +0200
@@ -268,6 +268,18 @@
         elif (isinstance(called, astng.Function) or
               isinstance(called, astng.Lambda)):
             pass
+        elif isinstance(called, astng.Class):
+            method = called.lookup('__init__')[1]
+            if len(method) == 1:
+              called = method[0]
+              # __init__ method have an extra implicit 'self' argument.
+              num_positional_args += 1
+            else:
+              #XXX deal with default class constructor (no params)
+              return
+        elif isinstance(called, astng.Instance) and called.callable():
+            called = called.getattr('__call__')[0]
+            num_positional_args += 1
         else:
             return