import attr


def IntParameter(default, unit=None, **kwargs):
    """Adds an integer parameter.

    Args:
        default (int): 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=int, **kwargs)