import socket
from typing import cast


def find_available_port() -> int:
    """Finds a local unoccupied port."""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.bind(("127.0.0.1", 0))
        _, port = s.getsockname()

    return cast(int, port)