mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
calling non callable inspection recognizes callable type (CR-PY-203)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user