boolean (@Nullable PsiElement element, @Nullable PsiElement parent) { if (element instanceof PyClass || element instanceof PyFunction) { return true; } if (!(parent instanceof PyClass) && (element instanceof PyTargetExpression) && !((PyTargetExpression)element).isQualified()) { PsiElement e = element.getParent(); if (e instanceof PyAssignmentStatement) { e = e.getParent(); if (e instanceof PyFile) { return true; } } } return false; }