Skip to content

Commit 3de5002

Browse files
committed
Add Retry type hint to StacApiIO
Add `Retry` type hint so that a retry object so that the `HTTPAdapter`s are correctly mounted.
1 parent 1454437 commit 3de5002

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/usage.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ If you'd like to configure this behavior, e.g. to retry on some ``50x`` response
134134
retry = Retry(
135135
total=5, backoff_factor=1, status_forcelist=[502, 503, 504], allowed_methods=None
136136
)
137-
stac_api_io = StacApiIO()
138-
stac_api_io.session.mount("https://", HTTPAdapter(max_retries=retry))
137+
stac_api_io = StacApiIO(max_retries=retry)
139138
client = Client.open(
140139
"https://planetarycomputer.microsoft.com/api/stac/v1", stac_io=stac_api_io
141140
)

pystac_client/stac_api_io.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pystac.stac_io import DefaultStacIO
2727
from requests import Request, Session
2828
from requests.adapters import HTTPAdapter
29+
from urllib3 import Retry
2930

3031
import pystac_client
3132

@@ -49,7 +50,7 @@ def __init__(
4950
parameters: Optional[Dict[str, Any]] = None,
5051
request_modifier: Optional[Callable[[Request], Union[Request, None]]] = None,
5152
timeout: Optional[Timeout] = None,
52-
max_retries: Optional[int] = 5,
53+
max_retries: Optional[Union[int, Retry]] = 5,
5354
):
5455
"""Initialize class for API IO
5556

0 commit comments

Comments
 (0)