calling non callable inspection recognizes callable type (CR-PY-203)

This commit is contained in:
Dmitry Jemerov
2011-08-15 19:47:48 +04:00
parent 7adce93c06
commit c5408c48d3
3 changed files with 12 additions and 6 deletions
@@ -10,10 +10,7 @@ import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.PyReferenceExpression;
import com.jetbrains.python.psi.impl.PyBuiltinCache;
import com.jetbrains.python.psi.resolve.QualifiedResolveResult;
import com.jetbrains.python.psi.types.PyABCUtil;
import com.jetbrains.python.psi.types.PyClassType;
import com.jetbrains.python.psi.types.PyType;
import com.jetbrains.python.psi.types.PyTypeReference;
import com.jetbrains.python.psi.types.*;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -63,7 +60,7 @@ public class PyCallingNonCallableInspection extends PyInspection {
registerProblem(node, String.format("'%s' object is not callable", cls.getName()));
}
}
else if (calleeType != null && !(calleeType instanceof PyTypeReference)) {
else if (calleeType != null && !(calleeType instanceof PyTypeReference) && !(calleeType instanceof PyCallableType)) {
registerProblem(node, String.format("'%s' is not callable", callee.getName()));
}
}
@@ -0,0 +1,5 @@
from collections import namedtuple
Point = namedtuple('Point', ['x', 'y'], verbose=True)
p = Point(11, y=22)
@@ -31,8 +31,12 @@ public class PyCallingNonCallableTest extends PyLightFixtureTestCase {
doTest();
}
public void testNamedTupleCallable() {
doTest();
}
private void doTest() {
setLanguageLevel(LanguageLevel.PYTHON26);
setLanguageLevel(LanguageLevel.PYTHON27);
try {
myFixture.configureByFile("inspections/PyCallingNonCallableInspection/" + getTestName(true) + ".py");
myFixture.enableInspections(PyCallingNonCallableInspection.class);