PsiElement (@NotNull PyClass cls, @NotNull String name, boolean isDefinition) { final PyFunction function = cls.findMethodByName(name, false, null); if (function != null) { final PyUtil.MethodFlags methodFlags = PyUtil.MethodFlags.of(function); final boolean instanceMethod = methodFlags == null || methodFlags.isInstanceMethod(); if (isDefinition ^ instanceMethod) { return function; } } if (!isDefinition) { final PyTargetExpression instanceAttribute = cls.findInstanceAttribute(name, false); if (instanceAttribute != null) { return instanceAttribute; } } final PyTargetExpression classAttribute = cls.findClassAttribute(name, false, null); if (classAttribute != null) { return classAttribute; } return null; }