diff --git a/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java b/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java index be64b32af41a..c045b17c53a2 100644 --- a/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java @@ -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())); } } diff --git a/python/testData/inspections/PyCallingNonCallableInspection/namedTupleCallable.py b/python/testData/inspections/PyCallingNonCallableInspection/namedTupleCallable.py new file mode 100644 index 000000000000..72f070e1eea8 --- /dev/null +++ b/python/testData/inspections/PyCallingNonCallableInspection/namedTupleCallable.py @@ -0,0 +1,5 @@ +from collections import namedtuple + +Point = namedtuple('Point', ['x', 'y'], verbose=True) + +p = Point(11, y=22) diff --git a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java index 11f83a71988e..3d656581bbfc 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java @@ -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);