mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
fixed PY-11588 "Instance attribute %s defined outside __init__" in static method
This commit is contained in:
@@ -70,6 +70,9 @@ public class PyAttributeOutsideInitInspection extends PyInspection {
|
||||
if (!isApplicable(containingClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PyFunction.Modifier modifier = node.getModifier();
|
||||
if (modifier != null) return;
|
||||
final List<PyTargetExpression> classAttributes = containingClass.getClassAttributes();
|
||||
|
||||
Map<String, PyTargetExpression> attributesInInit = new HashMap<String, PyTargetExpression>();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class C(object):
|
||||
|
||||
@staticmethod
|
||||
def static_method(obj, name):
|
||||
obj.name = name # warning here
|
||||
@@ -62,6 +62,10 @@ public class PyAttributeOutsideInitInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("inspections/PyAttributeOutsideInitInspection/" + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyAttributeOutsideInitInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user