mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-25076 Method may be static checks compares only unqualified references with "self"
This commit is contained in:
@@ -113,8 +113,10 @@ public class PyMethodMayBeStaticInspection extends PyInspection {
|
||||
|
||||
@Override
|
||||
public void visitPyReferenceExpression(PyReferenceExpression node) {
|
||||
super.visitPyReferenceExpression(node);
|
||||
if (selfName.equals(node.getName())) {
|
||||
if (node.isQualified()) {
|
||||
super.visitPyReferenceExpression(node);
|
||||
}
|
||||
else if (selfName.equals(node.getName())) {
|
||||
mayBeStatic[0] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
x = object()
|
||||
x.self = 42
|
||||
|
||||
|
||||
class C:
|
||||
def <weak_warning descr="Method 'method' may be 'static'">method</weak_warning>(self):
|
||||
print(x.self)
|
||||
@@ -115,6 +115,11 @@ public class PyMethodMayBeStaticInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-25076
|
||||
public void testAttributeNamedSelf() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyMethodMayBeStaticInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user