valyu 2.13.9
Standard API SDK, ordinary HTTP client code
Python JSON parsing or serialization referenceCalls get with a q/query key
SHA-256b75302b020ce2017578c92e35b67eea742e07c1c0cc6213aaf6811d6f9b7ab9b
Evidence
11:35… d :: MIT License
12Classifier: Operating System :: OS Independent
13Requires-Python: >=3.6
14Description-Content-Type: text/markdown
15Requires-Dist: requests>=2.31.0
16Requires-Dist: httpx>=0.27.0
17Requires-Dist: pydantic>=2.0.0
18Dynamic: author
⋯4 lines
27:25…
28Dynamic: summary
29
30# Valyu Python SDK
31
32[](https://pypi.org/project/valyu/)
33[](https: …
1"""
2Shared error-message formatting for Valyu API responses.
3"""
4
5from typing import Any, Dict
6
7
8def error_message(data: Dict[str, Any], status_code: int) -> str:
9 """
10 Build a human-readable error string from an API error body.
11
12 Validation failures carry an `errors` array naming each offending field, so
13 fold those into the message. Without them a caller only sees a summary like
14 "2 validation errors", which says nothing about which parameter was wrong or
15 what the API expected instead.
⋯4 lines
20
21 Returns:
22 The error message, suffixed with per-field detail when available
23 """
24 if not isinstance(data, dict):
25 return f"HTTP Error: {status_code}"
26
27 summary = data.get("message") or data.get("error") or f"HTTP Error: {status_code}"
28
29 details = []
30 for item in data.get("errors") or []:
31 if isinstance(item, dict):
32 detail = item.get("message") or item.get("code")
33 key = item.get("key")
34 if detail and key and key not in str(detail):
35 detail = f"{key}: {detail}"
36 else:
⋯8 lines
1"""
2Shared HTTP 429 (rate-limit) handling: the structured detail built from a
3429 response, and the retry helper every create-style call reuses.
4"""
5
6import asyncio
7import time
8from typing import Any, Awaitable, Callable, Mapping, Optional, Protocol, TypeVar
9
10from valyu.types.rate_limit import RateLimitDetail, RateLimitInfo
11
12# Used only when a 429 body carries neither `retry_after` nor a `Retry-After`
13# header — a c …
36:65… o whole seconds."""
37 if not headers:
38 return None
39 value = headers.get("Retry-After")
40 if value is None:
41 return None
42 try:
43 return max(0, int(float(value)))
44 except (TypeError, ValueError) …
Showing the top 5 files — 7 more files (89 regions) not shown.
No evidence locations were recorded for this file. Raw result