PyExpression () { final LanguageLevel level = LanguageLevel.forElement(this); if (!level.isPython2()) { // Requires AST access for (PyExpression expression : getSuperClassExpressions()) { if (expression instanceof PyKeywordArgument argument) { if (PyNames.METACLASS.equals(argument.getKeyword())) { return argument.getValueExpression(); } } } } else { final PyTargetExpression attribute = findClassAttribute(PyNames.DUNDER_METACLASS, false, null); if (attribute != null) { return attribute.findAssignedValue(); } } for (PyExpression expression : getSuperClassExpressions()) { if (isSixWithMetaclassCall(expression)) { final PyExpression[] arguments = ((PyCallExpression)expression).getArguments(); if (arguments.length != 0) { return arguments[0]; } } } final PyDecoratorList decoratorList = getDecoratorList(); if (decoratorList != null) { for (PyDecorator decorator : decoratorList.getDecorators()) { if (isSixAddMetaclass(decorator)) { final PyExpression[] arguments = decorator.getArguments(); if (arguments.length != 0) { return arguments[0]; } } } } return null; }