mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-11981 "PEP 8 naming convention violation" inspection treats class attributes as function variables
This commit is contained in:
@@ -28,8 +28,6 @@ import com.jetbrains.python.codeInsight.controlflow.ControlFlowCache;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.Scope;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.search.PySuperMethodsSearch;
|
||||
import com.jetbrains.python.psi.types.PyModuleType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.testing.pytest.PyTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -77,8 +75,7 @@ public class PyPep8NamingInspection extends PyInspection {
|
||||
if (expression instanceof PyTargetExpression) {
|
||||
final PyExpression qualifier = ((PyTargetExpression)expression).getQualifier();
|
||||
if (qualifier != null) {
|
||||
final PyType type = myTypeEvalContext.getType(qualifier);
|
||||
if (type instanceof PyModuleType) return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!LOWERCASE_REGEX.matcher(name).matches() && !name.startsWith("_")) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Spam(object):
|
||||
CLASS_FIELD = 0
|
||||
|
||||
@classmethod
|
||||
def eggs(cls):
|
||||
cls.CLASS_FIELD = 1
|
||||
|
||||
@staticmethod
|
||||
def ham():
|
||||
Spam.CLASS_FIELD = 2
|
||||
@@ -58,6 +58,10 @@ public class PyPep8NamingInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testClassAttributes() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTest() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user