boolean (PyClass pyClass) { final PsiFile containingFile = pyClass.getContainingFile(); if (containingFile instanceof PyFile) { final PsiElement element = ((PyFile)containingFile).getElementNamed(PyNames.DUNDER_METACLASS); if (element instanceof PyTargetExpression) { final QualifiedName qName = ((PyTargetExpression)element).getAssignedQName(); if (qName != null && qName.matches("type")) { return true; } } } if (pyClass.findClassAttribute(PyNames.DUNDER_METACLASS, false, null) != null) { return true; } return false; }