imf_reader.utils ================ .. py:module:: imf_reader.utils .. autoapi-nested-parse:: Utility functions Attributes ---------- .. autoapisummary:: imf_reader.utils.make_request Functions --------- .. autoapisummary:: imf_reader.utils._raise_connection_error imf_reader.utils.make_get_request imf_reader.utils.make_post_request Module Contents --------------- .. py:function:: _raise_connection_error(url: str, exc: Exception) -> NoReturn Translate a requests exception into ConnectionError and raise it. Always raises; return type Never so callers' control flow is understood. .. py:function:: make_get_request(url: str, *, use_http_cache: bool = True) -> requests.Response Make a GET request through the shared CachedSession. When caching is disabled (e.g. via ``cache.disable_cache()``), falls through to bare ``requests.get`` so test patches on ``requests.get`` keep working. :param url: URL to request. :param use_http_cache: When ``False``, bypass the requests-cache layer for this call and go through bare ``requests.get``. Use this for payloads that have their own bulk-cache layer (e.g. validated SDMX zips handled by ``CacheManager``) so a corrupt response cannot be retained by the HTTP cache and re-served on retry. :returns: the response object. :rtype: requests.Response :raises ConnectionError: on any network failure or non-2xx HTTP response. The cache does not silently fall back to stale data on 5xx (``stale_if_error=False``). .. py:function:: make_post_request(url: str, *, data: dict | None = None, use_http_cache: bool = True) -> requests.Response Make a POST request through the shared CachedSession. When caching is disabled, falls through to bare ``requests.post``. :param url: URL to POST to. :param data: Optional form data dict. :param use_http_cache: When ``False``, bypass the requests-cache layer for this call (see :func:`make_get_request` for rationale). :returns: the response object. :rtype: requests.Response :raises ConnectionError: on any network failure or non-2xx HTTP response. Same ``stale_if_error=False`` contract as ``make_get_request``. .. py:data:: make_request