from typing import Optional


def hex_str(packet: bytes, display_limit: Optional[int] = 16) -> str:
    """
    convert bytes into hex-string
    :param packet: packet to convert
    :param display_limit: limit of number of bytes to display, None to set it infinite.
    """
    if display_limit is None:
        return packet.hex(sep=" ").upper()
    else:
        display_limit = min(display_limit, len(packet))
        ret = packet[:display_limit].hex(sep=" ").upper()
        ret += f"... ({len(packet) - display_limit} bytes left)"
        return ret