from typing import Literal


def int_to_bytes(num: int, order: Literal["little", "big"] = "big", byte_size=None) -> bytes:
    """
    Convert a positive int to a bytes string. if byte_size kwarg is None, a byte string with
    enough length to contain the integer will be calculated and used.

    :param num: a positive int
    :param order: "big" or "little"
    :param byte_size: Optional byte string size, automatically calculated if left None
    :return: bytes representation of the given positive num
    """
    return num.to_bytes(byte_size or (num.bit_length() + 7) // 8 or 1, order, signed=False)