hyperion/models/util.py
async def get_postcode_random() -> Postcode:
    """
    Gets a random postcode object..
    Acts as a middleware between us and the API, caching results.
    :return: The PostCode object else None if the postcode does not exist.
    """
    try:
        postcode = await fetch_postcode_random()
    except (ApiError, CircuitBreakerError):
        raise CachingError(f"Requested postcode is not cached, and can't be retrieved.")

    if postcode is not None:
        postcode.save()
    return postcode
async def get_postcode_random() -> Postcode:
    """
    Gets a random postcode object..
    Acts as a middleware between us and the API, caching results.
    :return: The PostCode object else None if the postcode does not exist.
    """
    try:
        postcode = await fetch_postcode_random()
    except (ApiError, CircuitBreakerError):
        raise CachingError(f"Requested postcode is not cached, and can't be retrieved.")

    if postcode is not None:
        postcode.save()
    return postcode
Gets a random postcode object..
    Acts as a middleware between us and the API, caching results.
    :return: The PostCode object else None if the postcode does not exist.