sub_class_meta.py (Source)

class BaseMeta(type):

    def __new__(cls, name, bases, body):
        if 'to_json' not in body:
            raise TypeError("Bad Class you are missing something")
        return super().__new__(cls, name, bases, body)


class Base(metaclass=BaseMeta):
    def to_json():
        return "bar"