mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-15 20:26:04 +07:00
fixed PY-11500 False positive in method may be static inspection for decorated methods
This commit is contained in:
@@ -70,7 +70,9 @@ public class PyMethodMayBeStaticInspection extends PyInspection {
|
||||
if (!supers.isEmpty()) return;
|
||||
final Collection<PyFunction> overrides = PyOverridingMethodsSearch.search(node, true).findAll();
|
||||
if (!overrides.isEmpty()) return;
|
||||
if (PyUtil.isDecoratedAsAbstract(node) || node.getModifier() != null) return;
|
||||
final PyDecoratorList decoratorList = node.getDecoratorList();
|
||||
if (decoratorList != null) return;
|
||||
if (node.getModifier() != null) return;
|
||||
final Property property = containingClass.findPropertyByCallable(node);
|
||||
if (property != null) return;
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
def bar(f):
|
||||
def wrapper(self, *args, **kwargs):
|
||||
print('running {cls}.{method}'.format(cls=type(self).__name__,
|
||||
method=f.__name__))
|
||||
return f(self, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
class C(object):
|
||||
@bar
|
||||
def foo(self): # False positive: self is used by @bar
|
||||
return 'foo'
|
||||
|
||||
|
||||
C().foo()
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.jetbrains.python.PythonTestUtil;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
|
||||
@@ -23,6 +24,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* User: ktisha
|
||||
*/
|
||||
@TestDataPath("$CONTENT_ROOT/../testData/inspections/PyMethodMayBeStaticInspection/")
|
||||
public class PyMethodMayBeStaticInspectionTest extends PyTestCase {
|
||||
|
||||
public void testTruePositive() {
|
||||
@@ -65,6 +67,10 @@ public class PyMethodMayBeStaticInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDecorated() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOverwrittenMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user