from typing import Any
import requests


def request_with_retry(
    method: str, url: str, **kwargs: Any
) -> requests.models.Response:
    """
    Wrapper function for `requests.request` that retries
    timeout, connection, and server-side http errors with
    exponential backoff and jitter. For more info:
    https://docs.python-requests.org/en/latest/api/#requests.request
    """
    response = requests.request(method, url, **kwargs)
    if 500 <= response.status_code < 600:
        response.raise_for_status()
    return response