boolean (@NotNull PyExpression expression) { if (expression instanceof PyCallExpression){ final PyExpression callee = ((PyCallExpression)expression).getCallee(); if (callee instanceof PyReferenceExpression) { final QualifiedName sixWithMetaclass = QualifiedName.fromComponents("six", "with_metaclass"); final QualifiedName djangoWithMetaclass = QualifiedName.fromDottedString("django.utils.six.with_metaclass"); return ContainerUtil.exists(PyResolveUtil.resolveImportedElementQNameLocally((PyReferenceExpression)callee), name -> name.equals(sixWithMetaclass) || name.equals(djangoWithMetaclass)); } } return false; }