Coverage for src/retrospeedlab/lake/sources/http.py: 100%
13 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-12-02 22:44 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-12-02 22:44 +0000
1from typing import Any
3import httpx
5from retrospeedlab.retry import transient_retry
7TIMEOUT_SECONDS = 30.0
10def client(base_url: str, headers: dict[str, str]) -> httpx.Client:
11 return httpx.Client(base_url=base_url, headers=headers, timeout=TIMEOUT_SECONDS)
14@transient_retry
15def sent(
16 session: httpx.Client, method: str, path: str, params: dict[str, Any], body: dict[str, Any] | list[Any] | None
17) -> httpx.Response:
18 response = session.request(method, path, params=params, json=body)
19 response.raise_for_status()
20 return response
23def get_json(session: httpx.Client, path: str, params: dict[str, Any]) -> Any:
24 return sent(session, "GET", path, params, None).json()