def __new__(cls, name, bases, attrs):
        attrs['base_fields'] = {}
        declared_fields = {}

        try:
            parents = [b for b in bases if issubclass(b, ModelDataset)]
            parents.reverse()

            for p in parents:
                parent_fields = getattr(p, 'base_fields', {})

                for field_name, field_object in parent_fields.items():
                    attrs['base_fields'][field_name] = deepcopy(field_object)
        except __HOLE__:
            pass

        for field_name, obj in attrs.copy().items():
            if issubclass(type(obj), Field):
                field = attrs.pop(field_name)
                declared_fields[field_name] = field

        attrs['base_fields'].update(declared_fields)
        attrs['declared_fields'] = declared_fields

        new_class = super(DatasetMetaclass, cls).__new__(cls, name,
                                                         bases, attrs)
        opts = new_class._meta = DatasetOptions(getattr(new_class,
                                                        'Meta', None))

        if new_class.__name__ == 'ModelDataset':
            return new_class

        if not opts.model and not opts.queryset:
            raise NoObjectsException("You must set a model or non-empty "
                                     "queryset for each Dataset subclass")
        if opts.queryset is not None:
            queryset = opts.queryset
            model = queryset.model
            new_class.queryset = queryset
            new_class.model = model
        else:
            model = opts.model
            queryset = model.objects.all()
            new_class.model = model
            new_class.queryset = queryset

        return new_class
dataset/ETHPy150Open joshourisman/django-tablib/django_tablib/models.py/DatasetMetaclass.__new__