import attr


def FloatParameter(default, unit=None, **kwargs):
    """Adds a float parameter.

    Args:
        default (float): Default value.
        unit (optional, str): Unit to record in metadata.
            Default: None.
    """
    if unit is not None:
        kwargs["metadata"] = dict(unit=str(unit))
    return attr.ib(default=default, converter=float, **kwargs)