sharpapi 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sharpapi-0.3.2 → sharpapi-0.3.3}/.gitignore +0 -1
- {sharpapi-0.3.2 → sharpapi-0.3.3}/PKG-INFO +1 -1
- {sharpapi-0.3.2 → sharpapi-0.3.3}/pyproject.toml +1 -1
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/_base.py +9 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/async_client.py +2 -1
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/client.py +2 -1
- {sharpapi-0.3.2 → sharpapi-0.3.3}/CHANGELOG.md +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/LICENSE +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/README.md +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/SECURITY.md +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/__init__.py +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/_utils.py +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/exceptions.py +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/models.py +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/py.typed +0 -0
- {sharpapi-0.3.2 → sharpapi-0.3.3}/src/sharpapi/streaming.py +0 -0
|
@@ -33,6 +33,15 @@ RETRY_BASE_DELAY = 0.5
|
|
|
33
33
|
RETRY_MAX_DELAY = 4.0
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def normalize_base_url(base_url: str) -> str:
|
|
37
|
+
"""Return the API origin URL, accepting values with a trailing /api/v1."""
|
|
38
|
+
cleaned = base_url.rstrip("/")
|
|
39
|
+
suffix = "/api/v1"
|
|
40
|
+
if cleaned.endswith(suffix):
|
|
41
|
+
return cleaned[: -len(suffix)]
|
|
42
|
+
return cleaned
|
|
43
|
+
|
|
44
|
+
|
|
36
45
|
def should_retry(response: httpx.Response | None, exc: Exception | None) -> bool:
|
|
37
46
|
"""True for transient upstream failures worth retrying."""
|
|
38
47
|
if exc is not None:
|
|
@@ -15,6 +15,7 @@ from ._base import (
|
|
|
15
15
|
AuthMethod,
|
|
16
16
|
handle_errors,
|
|
17
17
|
make_headers,
|
|
18
|
+
normalize_base_url,
|
|
18
19
|
parse_rate_limit,
|
|
19
20
|
parse_response,
|
|
20
21
|
retry_delay,
|
|
@@ -89,7 +90,7 @@ class AsyncSharpAPI:
|
|
|
89
90
|
|
|
90
91
|
self._api_key = api_key
|
|
91
92
|
self._auth_method: AuthMethod = auth_method
|
|
92
|
-
self._base_url = base_url
|
|
93
|
+
self._base_url = normalize_base_url(base_url)
|
|
93
94
|
self._timeout = timeout
|
|
94
95
|
self._http = httpx.AsyncClient(
|
|
95
96
|
base_url=f"{self._base_url}/api/v1",
|
|
@@ -15,6 +15,7 @@ from ._base import (
|
|
|
15
15
|
AuthMethod,
|
|
16
16
|
handle_errors,
|
|
17
17
|
make_headers,
|
|
18
|
+
normalize_base_url,
|
|
18
19
|
parse_rate_limit,
|
|
19
20
|
parse_response,
|
|
20
21
|
retry_delay,
|
|
@@ -97,7 +98,7 @@ class SharpAPI:
|
|
|
97
98
|
|
|
98
99
|
self._api_key = api_key
|
|
99
100
|
self._auth_method: AuthMethod = auth_method
|
|
100
|
-
self._base_url = base_url
|
|
101
|
+
self._base_url = normalize_base_url(base_url)
|
|
101
102
|
self._timeout = timeout
|
|
102
103
|
self._http = httpx.Client(
|
|
103
104
|
base_url=f"{self._base_url}/api/v1",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|