def format_nums(number, decimals):
    """
    rounds to a number of decimals and if possible makes  a integer from float

    :param number: input number
    :param decimals: decimals to round to
    :return: integer or float
    """
    if round(float(number), decimals).is_integer():
        return int(f"{number:.0f}")

    return float(f"{number:.{decimals}f}")