from typing import Union


def num_format(num: Union[int,float], precision: int = 3) -> str:
    """Return a properly formated string for a number at some precision.

    Formats a number to some precesion with trailing 0 and . removed.

    Args:
        num (Union[int,float]): Number to be formatted.
        precision (int, optional): Precision to use. Defaults to 3.

    Returns:
        str: String representation of the number."""
    return ('%.*f' % (precision, num)).rstrip('0').rstrip('.')