diff --git a/python/src/com/jetbrains/python/psi/types/PyABCUtil.java b/python/src/com/jetbrains/python/psi/types/PyABCUtil.java index 21833152f3ca..78cd56cc2a0e 100644 --- a/python/src/com/jetbrains/python/psi/types/PyABCUtil.java +++ b/python/src/com/jetbrains/python/psi/types/PyABCUtil.java @@ -85,6 +85,6 @@ public class PyABCUtil { } private static boolean hasMethod(PyClass cls, String name, boolean inherited) { - return cls.findMethodByName(name, inherited) != null; + return cls.findMethodByName(name, inherited) != null || cls.findClassAttribute(name, inherited) != null; } } diff --git a/python/testData/inspections/PyCallingNonCallableInspection/callAttributeAssignment.py b/python/testData/inspections/PyCallingNonCallableInspection/callAttributeAssignment.py new file mode 100644 index 000000000000..bbe8675ce7e1 --- /dev/null +++ b/python/testData/inspections/PyCallingNonCallableInspection/callAttributeAssignment.py @@ -0,0 +1,9 @@ +class C: + def f(self): + pass + + __call__ = f + + +c = C() +c() # pass diff --git a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableInspectionTest.java index 6d51254669d7..8f8441c2367c 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableInspectionTest.java @@ -54,6 +54,11 @@ public class PyCallingNonCallableInspectionTest extends PyTestCase { doTest(); } + // PY-8416 + public void testCallAttributeAssignment() { + doTest(); + } + private void doTest() { setLanguageLevel(LanguageLevel.PYTHON27); try {