def format_snap_name(snap, *, allow_empty_version: bool=False) ->str:
    """Return a filename representing the snap depending on snap attributes.

    :param dict snap: a dictionary of keys containing name, version and arch.
    :param bool allow_empty_version: if set a filename without a version is
                                     allowed.
    """
    if allow_empty_version and snap.get('version') is None:
        extension = '{name}_{arch}.snap'
    else:
        extension = '{name}_{version}_{arch}.snap'
    if 'arch' not in snap:
        snap['arch'] = snap.get('architectures', None)
    if not snap['arch']:
        snap['arch'] = 'all'
    elif len(snap['arch']) == 1:
        snap['arch'] = snap['arch'][0]
    else:
        snap['arch'] = 'multi'
    return extension.format(**snap)
