def abstract(class_):
    if not inspect.isclass(class_):
        raise TypeError("@abstract can only be applied to classes")
    abc_meta = None
    class_meta = type(class_)
    if class_meta not in (_ABCMetaclass, _ABCObjectMetaclass):
        if class_meta is type:
            abc_meta = _ABCMetaclass
        elif class_meta is ObjectMetaclass:
            abc_meta = _ABCObjectMetaclass
        else:
            raise ValueError(
                "@abstract cannot be applied to classes with custom metaclass")
    class_.__abstract__ = True
    return metaclass(abc_meta)(class_) if abc_meta else class_