from attr import ib, Factory


def Field(*args, **kwargs):
    default = kwargs.get('default')
    if callable(default):
        kwargs.pop('default')
        return ib(*args, default=Factory(default), **kwargs)
    else:
        return ib(*args, **kwargs)

import attr


def Field(*args, default=attr.NOTHING, **kwargs):
    if callable(default):
        default = attr.Factory(default)

    return attr.ib(*args, default=default, **kwargs)


def ManyToManyField(cls, *args, **kwargs):
    metadata = {
        'related': {
            'target': cls,
            'type': 'ManyToMany',
        }
    }

    return attr.ib(*args, **kwargs, metadata=metadata)

Introduce dummy ManyToManyField with attrs metadata