Skip to content

Commit ec5edbb

Browse files
committed
Bump
1 parent dc06ffe commit ec5edbb

11 files changed

Lines changed: 261 additions & 252 deletions

lithic/_base_client.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@
2626
import pydantic
2727
from pydantic import PrivateAttr
2828

29-
from ._types import Query, ModelT, Timeout, Transport, ProxiesTypes, RequestOptions
29+
from ._types import (
30+
Query,
31+
ModelT,
32+
Timeout,
33+
NotGiven,
34+
Transport,
35+
ProxiesTypes,
36+
RequestOptions,
37+
)
3038
from ._models import BaseModel, NoneModel, GenericModel, FinalRequestOptions
3139
from .exceptions import (
3240
APITimeoutError,
@@ -640,19 +648,19 @@ def get_api_list(
640648

641649

642650
def make_request_options(
643-
headers: Dict[str, str] | None = None,
644-
max_retries: int | None = None,
645-
timeout: float | Timeout | None = None,
651+
headers: Dict[str, str] | NotGiven,
652+
max_retries: int | NotGiven,
653+
timeout: float | Timeout | None | NotGiven,
646654
) -> RequestOptions:
647-
"""Create a dict of type RequestOptions without keys of None values."""
655+
"""Create a dict of type RequestOptions without keys of NotGiven values."""
648656
options: RequestOptions = {}
649-
if headers is not None:
657+
if not isinstance(headers, NotGiven):
650658
options["headers"] = headers
651659

652-
if max_retries is not None:
660+
if not isinstance(max_retries, NotGiven):
653661
options["max_retries"] = max_retries
654662

655-
if timeout is not None:
663+
if not isinstance(timeout, NotGiven):
656664
options["timeout"] = timeout
657665

658666
return options

lithic/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing_extensions import Literal
77

88
from . import resources
9-
from ._types import Timeout, Transport, ProxiesTypes, RequestOptions
9+
from ._types import Timeout, NotGiven, Transport, ProxiesTypes, RequestOptions
1010
from ._version import __version__
1111
from ._base_client import (
1212
DEFAULT_TIMEOUT,

lithic/_types.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Union, Mapping, TypeVar
1+
from typing import Dict, Union, Literal, Mapping, TypeVar
22

33
import pydantic
44
from httpx import Proxy, Timeout, BaseTransport
@@ -15,24 +15,25 @@
1515
class RequestOptions(TypedDict, total=False):
1616
headers: Dict[str, str]
1717
max_retries: int
18-
timeout: Union[float, Timeout]
18+
timeout: Union[float, Timeout, None]
1919

2020

2121
# Sentinel class used until PEP 0661 is accepted
2222
class NotGiven:
23-
"""For certain parameters such as `timeout=...` the intent can be made more clear
24-
by typing the parameter with this class rather than using None, for example:
25-
26-
```py
27-
def get(timeout: Union[int, NotGiven] = NotGiven()) -> Response: ...
28-
```
23+
"""
24+
A sentinel singleton class used to distinguish omitted keyword arguments
25+
from those passed in with the value None (which may have different behavior).
2926
30-
relays the intention more clearly than:
27+
For example:
3128
3229
```py
33-
def get(timeout: Optional[int] = None) -> Response: ...
34-
```
30+
def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
3531
36-
This solution also allows you to indicate an "unset" state that is uniquely distinct
37-
from `None` which means you can explicitly pass `None` to disable the timeout entirely.
32+
get(timout=1) # 1s timeout
33+
get(timout=None) # No timeout
34+
get() # Default timeout behavior, which may not be statically known at the method definition.
35+
```
3836
"""
37+
38+
def __bool__(self) -> Literal[False]:
39+
return False

lithic/resources/account_holders.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Dict, List, Union, Optional
44

5-
from .._types import Timeout
5+
from .._types import Timeout, NotGiven
66
from .._models import NoneModel, StringModel
77
from .._resource import SyncAPIResource, AsyncAPIResource
88
from .._base_client import AsyncPaginator, make_request_options
@@ -23,9 +23,9 @@ def create(
2323
self,
2424
body: AccountHolderCreateParams,
2525
*,
26-
headers: Optional[Dict[str, str]] = None,
27-
max_retries: Optional[int] = None,
28-
timeout: Optional[Union[float, Timeout]] = None,
26+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
27+
max_retries: Union[int, NotGiven] = NotGiven(),
28+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
2929
) -> AccountHolder:
3030
"""
3131
Run an individual or business's information through the Customer Identification
@@ -43,9 +43,9 @@ def retrieve(
4343
self,
4444
id: str,
4545
*,
46-
headers: Optional[Dict[str, str]] = None,
47-
max_retries: Optional[int] = None,
48-
timeout: Optional[Union[float, Timeout]] = None,
46+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
47+
max_retries: Union[int, NotGiven] = NotGiven(),
48+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
4949
) -> AccountHolder:
5050
"""Check the current status of a KYC or KYB evaluation."""
5151
options = make_request_options(headers, max_retries, timeout)
@@ -55,9 +55,9 @@ def create_webhook(
5555
self,
5656
body: AccountHolderCreateWebhookParams,
5757
*,
58-
headers: Optional[Dict[str, str]] = None,
59-
max_retries: Optional[int] = None,
60-
timeout: Optional[Union[float, Timeout]] = None,
58+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
59+
max_retries: Union[int, NotGiven] = NotGiven(),
60+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
6161
) -> AccountHolderCreateWebhookResponse:
6262
"""Create a webhook to receive KYC or KYB evaluation events.
6363
@@ -82,9 +82,9 @@ def list_documents(
8282
self,
8383
id: str,
8484
*,
85-
headers: Optional[Dict[str, str]] = None,
86-
max_retries: Optional[int] = None,
87-
timeout: Optional[Union[float, Timeout]] = None,
85+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
86+
max_retries: Union[int, NotGiven] = NotGiven(),
87+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
8888
) -> AccountHolderListDocumentsResponse:
8989
"""
9090
Retrieve the status of account holder document uploads, or retrieve the upload
@@ -111,9 +111,9 @@ def resubmit(
111111
id: str,
112112
body: AccountHolderResubmitParams,
113113
*,
114-
headers: Optional[Dict[str, str]] = None,
115-
max_retries: Optional[int] = None,
116-
timeout: Optional[Union[float, Timeout]] = None,
114+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
115+
max_retries: Union[int, NotGiven] = NotGiven(),
116+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
117117
) -> AccountHolder:
118118
"""Resubmit a KYC submission.
119119
@@ -134,9 +134,9 @@ def retrieve_document(
134134
account_holder_token: str,
135135
id: str,
136136
*,
137-
headers: Optional[Dict[str, str]] = None,
138-
max_retries: Optional[int] = None,
139-
timeout: Optional[Union[float, Timeout]] = None,
137+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
138+
max_retries: Union[int, NotGiven] = NotGiven(),
139+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
140140
) -> AccountHolderDocument:
141141
"""
142142
Check the status of an account holder document upload, or retrieve the upload
@@ -164,9 +164,9 @@ def upload_document(
164164
id: str,
165165
body: AccountHolderUploadDocumentParams,
166166
*,
167-
headers: Optional[Dict[str, str]] = None,
168-
max_retries: Optional[int] = None,
169-
timeout: Optional[Union[float, Timeout]] = None,
167+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
168+
max_retries: Union[int, NotGiven] = NotGiven(),
169+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
170170
) -> AccountHolderDocument:
171171
"""
172172
Use this endpoint to identify which type of supported government-issued
@@ -197,9 +197,9 @@ async def create(
197197
self,
198198
body: AccountHolderCreateParams,
199199
*,
200-
headers: Optional[Dict[str, str]] = None,
201-
max_retries: Optional[int] = None,
202-
timeout: Optional[Union[float, Timeout]] = None,
200+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
201+
max_retries: Union[int, NotGiven] = NotGiven(),
202+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
203203
) -> AccountHolder:
204204
"""
205205
Run an individual or business's information through the Customer Identification
@@ -217,9 +217,9 @@ async def retrieve(
217217
self,
218218
id: str,
219219
*,
220-
headers: Optional[Dict[str, str]] = None,
221-
max_retries: Optional[int] = None,
222-
timeout: Optional[Union[float, Timeout]] = None,
220+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
221+
max_retries: Union[int, NotGiven] = NotGiven(),
222+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
223223
) -> AccountHolder:
224224
"""Check the current status of a KYC or KYB evaluation."""
225225
options = make_request_options(headers, max_retries, timeout)
@@ -229,9 +229,9 @@ async def create_webhook(
229229
self,
230230
body: AccountHolderCreateWebhookParams,
231231
*,
232-
headers: Optional[Dict[str, str]] = None,
233-
max_retries: Optional[int] = None,
234-
timeout: Optional[Union[float, Timeout]] = None,
232+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
233+
max_retries: Union[int, NotGiven] = NotGiven(),
234+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
235235
) -> AccountHolderCreateWebhookResponse:
236236
"""Create a webhook to receive KYC or KYB evaluation events.
237237
@@ -256,9 +256,9 @@ async def list_documents(
256256
self,
257257
id: str,
258258
*,
259-
headers: Optional[Dict[str, str]] = None,
260-
max_retries: Optional[int] = None,
261-
timeout: Optional[Union[float, Timeout]] = None,
259+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
260+
max_retries: Union[int, NotGiven] = NotGiven(),
261+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
262262
) -> AccountHolderListDocumentsResponse:
263263
"""
264264
Retrieve the status of account holder document uploads, or retrieve the upload
@@ -287,9 +287,9 @@ async def resubmit(
287287
id: str,
288288
body: AccountHolderResubmitParams,
289289
*,
290-
headers: Optional[Dict[str, str]] = None,
291-
max_retries: Optional[int] = None,
292-
timeout: Optional[Union[float, Timeout]] = None,
290+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
291+
max_retries: Union[int, NotGiven] = NotGiven(),
292+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
293293
) -> AccountHolder:
294294
"""Resubmit a KYC submission.
295295
@@ -310,9 +310,9 @@ async def retrieve_document(
310310
account_holder_token: str,
311311
id: str,
312312
*,
313-
headers: Optional[Dict[str, str]] = None,
314-
max_retries: Optional[int] = None,
315-
timeout: Optional[Union[float, Timeout]] = None,
313+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
314+
max_retries: Union[int, NotGiven] = NotGiven(),
315+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
316316
) -> AccountHolderDocument:
317317
"""
318318
Check the status of an account holder document upload, or retrieve the upload
@@ -340,9 +340,9 @@ async def upload_document(
340340
id: str,
341341
body: AccountHolderUploadDocumentParams,
342342
*,
343-
headers: Optional[Dict[str, str]] = None,
344-
max_retries: Optional[int] = None,
345-
timeout: Optional[Union[float, Timeout]] = None,
343+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
344+
max_retries: Union[int, NotGiven] = NotGiven(),
345+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
346346
) -> AccountHolderDocument:
347347
"""
348348
Use this endpoint to identify which type of supported government-issued

lithic/resources/accounts.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Dict, List, Union, Optional
44

5-
from .._types import Timeout
5+
from .._types import Timeout, NotGiven
66
from .._models import NoneModel, StringModel
77
from .._resource import SyncAPIResource, AsyncAPIResource
88
from ..pagination import SyncPage, AsyncPage
@@ -19,9 +19,9 @@ def retrieve(
1919
self,
2020
id: str,
2121
*,
22-
headers: Optional[Dict[str, str]] = None,
23-
max_retries: Optional[int] = None,
24-
timeout: Optional[Union[float, Timeout]] = None,
22+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
23+
max_retries: Union[int, NotGiven] = NotGiven(),
24+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
2525
) -> Account:
2626
"""Get account configuration such as spend limits."""
2727
options = make_request_options(headers, max_retries, timeout)
@@ -32,9 +32,9 @@ def update(
3232
id: str,
3333
body: AccountUpdateParams,
3434
*,
35-
headers: Optional[Dict[str, str]] = None,
36-
max_retries: Optional[int] = None,
37-
timeout: Optional[Union[float, Timeout]] = None,
35+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
36+
max_retries: Union[int, NotGiven] = NotGiven(),
37+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
3838
) -> Account:
3939
"""Update account configuration such as spend limits and verification address.
4040
@@ -51,9 +51,9 @@ def list(
5151
self,
5252
query: AccountListParams = {},
5353
*,
54-
headers: Optional[Dict[str, str]] = None,
55-
max_retries: Optional[int] = None,
56-
timeout: Optional[Union[float, Timeout]] = None,
54+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
55+
max_retries: Union[int, NotGiven] = NotGiven(),
56+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
5757
) -> SyncPage[Account]:
5858
"""List account configurations."""
5959
options = make_request_options(headers, max_retries, timeout)
@@ -65,9 +65,9 @@ async def retrieve(
6565
self,
6666
id: str,
6767
*,
68-
headers: Optional[Dict[str, str]] = None,
69-
max_retries: Optional[int] = None,
70-
timeout: Optional[Union[float, Timeout]] = None,
68+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
69+
max_retries: Union[int, NotGiven] = NotGiven(),
70+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
7171
) -> Account:
7272
"""Get account configuration such as spend limits."""
7373
options = make_request_options(headers, max_retries, timeout)
@@ -78,9 +78,9 @@ async def update(
7878
id: str,
7979
body: AccountUpdateParams,
8080
*,
81-
headers: Optional[Dict[str, str]] = None,
82-
max_retries: Optional[int] = None,
83-
timeout: Optional[Union[float, Timeout]] = None,
81+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
82+
max_retries: Union[int, NotGiven] = NotGiven(),
83+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
8484
) -> Account:
8585
"""Update account configuration such as spend limits and verification address.
8686
@@ -97,9 +97,9 @@ def list(
9797
self,
9898
query: AccountListParams = {},
9999
*,
100-
headers: Optional[Dict[str, str]] = None,
101-
max_retries: Optional[int] = None,
102-
timeout: Optional[Union[float, Timeout]] = None,
100+
headers: Union[Dict[str, str], NotGiven] = NotGiven(),
101+
max_retries: Union[int, NotGiven] = NotGiven(),
102+
timeout: Union[float, Timeout, None, NotGiven] = NotGiven(),
103103
) -> AsyncPaginator[Account, AsyncPage[Account]]:
104104
"""List account configurations."""
105105
options = make_request_options(headers, max_retries, timeout)

0 commit comments

Comments
 (0)