fixed PY-10881 Method may be static false positive on abc.abstractproperty

This commit is contained in:
Ekaterina Tuzova
2013-09-25 17:30:00 +04:00
parent c81e155f75
commit c5fc462c9a
3 changed files with 17 additions and 2 deletions
@@ -57,8 +57,7 @@ public class PyMethodMayBeStaticInspection extends PyInspection {
if (decoratorList != null) {
for (PyDecorator decorator : decoratorList.getDecorators()) {
final String decoratorName = decorator.getName();
if (PyNames.STATICMETHOD.equals(decoratorName) || PyNames.CLASSMETHOD.equals(decoratorName) ||
PyNames.ABSTRACTMETHOD.equals(decoratorName)) {
if (hasSpecificDecorator(decoratorName)) {
return;
}
final Property property = containingClass.findPropertyByCallable(node);
@@ -121,5 +120,9 @@ public class PyMethodMayBeStaticInspection extends PyInspection {
}
}
private static boolean hasSpecificDecorator(String decoratorName) {
return PyNames.STATICMETHOD.equals(decoratorName) || PyNames.CLASSMETHOD.equals(decoratorName) ||
PyNames.ABSTRACTMETHOD.equals(decoratorName) || PyNames.ABSTRACTPROPERTY.equals(decoratorName);
}
}
}
@@ -0,0 +1,8 @@
__author__ = 'ktisha'
import abc
class A(object):
@abc.abstractproperty
def foo(self):
print ""
@@ -55,6 +55,10 @@ public class PyMethodMayBeStaticInspectionTest extends PyTestCase {
doTest();
}
public void testAbstractProperty() {
doTest();
}
private void doTest() {
myFixture.configureByFile("inspections/PyMethodMayBeStaticInspection/" + getTestName(true) + ".py");
myFixture.enableInspections(PyMethodMayBeStaticInspection.class);