Skip to content

Commit 47fa6b2

Browse files
chore(types): change optional parameter type from NotGiven to Omit
1 parent 05e4248 commit 47fa6b2

251 files changed

Lines changed: 5542 additions & 5543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/telnyx/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import typing as _t
44

55
from . import types
6-
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
6+
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
77
from ._utils import file_from_path
88
from ._client import Client, Stream, Telnyx, Timeout, Transport, AsyncClient, AsyncStream, AsyncTelnyx, RequestOptions
99
from ._models import BaseModel
@@ -38,7 +38,9 @@
3838
"ProxiesTypes",
3939
"NotGiven",
4040
"NOT_GIVEN",
41+
"not_given",
4142
"Omit",
43+
"omit",
4244
"TelnyxError",
4345
"APIError",
4446
"APIStatusError",

src/telnyx/_base_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
from ._qs import Querystring
4343
from ._files import to_httpx_files, async_to_httpx_files
4444
from ._types import (
45-
NOT_GIVEN,
4645
Body,
4746
Omit,
4847
Query,
@@ -57,6 +56,7 @@
5756
RequestOptions,
5857
HttpxRequestFiles,
5958
ModelBuilderProtocol,
59+
not_given,
6060
)
6161
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
6262
from ._compat import PYDANTIC_V1, model_copy, model_dump
@@ -145,9 +145,9 @@ def __init__(
145145
def __init__(
146146
self,
147147
*,
148-
url: URL | NotGiven = NOT_GIVEN,
149-
json: Body | NotGiven = NOT_GIVEN,
150-
params: Query | NotGiven = NOT_GIVEN,
148+
url: URL | NotGiven = not_given,
149+
json: Body | NotGiven = not_given,
150+
params: Query | NotGiven = not_given,
151151
) -> None:
152152
self.url = url
153153
self.json = json
@@ -595,7 +595,7 @@ def _maybe_override_cast_to(self, cast_to: type[ResponseT], options: FinalReques
595595
# we internally support defining a temporary header to override the
596596
# default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
597597
# see _response.py for implementation details
598-
override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
598+
override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
599599
if is_given(override_cast_to):
600600
options.headers = headers
601601
return cast(Type[ResponseT], override_cast_to)
@@ -825,7 +825,7 @@ def __init__(
825825
version: str,
826826
base_url: str | URL,
827827
max_retries: int = DEFAULT_MAX_RETRIES,
828-
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
828+
timeout: float | Timeout | None | NotGiven = not_given,
829829
http_client: httpx.Client | None = None,
830830
custom_headers: Mapping[str, str] | None = None,
831831
custom_query: Mapping[str, object] | None = None,
@@ -1356,7 +1356,7 @@ def __init__(
13561356
base_url: str | URL,
13571357
_strict_response_validation: bool,
13581358
max_retries: int = DEFAULT_MAX_RETRIES,
1359-
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1359+
timeout: float | Timeout | None | NotGiven = not_given,
13601360
http_client: httpx.AsyncClient | None = None,
13611361
custom_headers: Mapping[str, str] | None = None,
13621362
custom_query: Mapping[str, object] | None = None,
@@ -1818,8 +1818,8 @@ def make_request_options(
18181818
extra_query: Query | None = None,
18191819
extra_body: Body | None = None,
18201820
idempotency_key: str | None = None,
1821-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1822-
post_parser: PostParser | NotGiven = NOT_GIVEN,
1821+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1822+
post_parser: PostParser | NotGiven = not_given,
18231823
) -> RequestOptions:
18241824
"""Create a dict of type RequestOptions without keys of NotGiven values."""
18251825
options: RequestOptions = {}

src/telnyx/_client.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import os
6-
from typing import Any, Union, Mapping, Iterable
6+
from typing import Any, Mapping, Iterable
77
from typing_extensions import Self, Literal, override
88

99
import httpx
@@ -18,7 +18,6 @@
1818
client_delete_objects_params,
1919
)
2020
from ._types import (
21-
NOT_GIVEN,
2221
Body,
2322
Omit,
2423
Query,
@@ -30,6 +29,8 @@
3029
Transport,
3130
ProxiesTypes,
3231
RequestOptions,
32+
omit,
33+
not_given,
3334
)
3435
from ._utils import (
3536
is_given,
@@ -376,7 +377,7 @@ def __init__(
376377
*,
377378
api_key: str | None = None,
378379
base_url: str | httpx.URL | None = None,
379-
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
380+
timeout: float | Timeout | None | NotGiven = not_given,
380381
max_retries: int = DEFAULT_MAX_RETRIES,
381382
default_headers: Mapping[str, str] | None = None,
382383
default_query: Mapping[str, object] | None = None,
@@ -605,9 +606,9 @@ def copy(
605606
*,
606607
api_key: str | None = None,
607608
base_url: str | httpx.URL | None = None,
608-
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
609+
timeout: float | Timeout | None | NotGiven = not_given,
609610
http_client: httpx.Client | None = None,
610-
max_retries: int | NotGiven = NOT_GIVEN,
611+
max_retries: int | NotGiven = not_given,
611612
default_headers: Mapping[str, str] | None = None,
612613
set_default_headers: Mapping[str, str] | None = None,
613614
default_query: Mapping[str, object] | None = None,
@@ -655,13 +656,13 @@ def create_bucket(
655656
self,
656657
bucket_name: str,
657658
*,
658-
location_constraint: str | NotGiven = NOT_GIVEN,
659+
location_constraint: str | Omit = omit,
659660
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
660661
# The extra values given here take precedence over values defined on the client or passed to this method.
661662
extra_headers: Headers | None = None,
662663
extra_query: Query | None = None,
663664
extra_body: Body | None = None,
664-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
665+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
665666
) -> None:
666667
"""
667668
Create a bucket.
@@ -698,7 +699,7 @@ def delete_bucket(
698699
extra_headers: Headers | None = None,
699700
extra_query: Query | None = None,
700701
extra_body: Body | None = None,
701-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
702+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
702703
) -> None:
703704
"""Deletes a bucket.
704705
@@ -734,7 +735,7 @@ def delete_object(
734735
extra_headers: Headers | None = None,
735736
extra_query: Query | None = None,
736737
extra_body: Body | None = None,
737-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
738+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
738739
) -> None:
739740
"""
740741
Delete an object from a given bucket.
@@ -772,7 +773,7 @@ def delete_objects(
772773
extra_headers: Headers | None = None,
773774
extra_query: Query | None = None,
774775
extra_body: Body | None = None,
775-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
776+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
776777
) -> object:
777778
"""
778779
Deletes one or multiple objects from a given bucket.
@@ -807,13 +808,13 @@ def get_object(
807808
object_name: str,
808809
*,
809810
bucket_name: str,
810-
upload_id: str | NotGiven = NOT_GIVEN,
811+
upload_id: str | Omit = omit,
811812
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
812813
# The extra values given here take precedence over values defined on the client or passed to this method.
813814
extra_headers: Headers | None = None,
814815
extra_query: Query | None = None,
815816
extra_body: Body | None = None,
816-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
817+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
817818
) -> BinaryAPIResponse:
818819
"""
819820
Retrieves an object from a given bucket.
@@ -852,7 +853,7 @@ def list_buckets(
852853
extra_headers: Headers | None = None,
853854
extra_query: Query | None = None,
854855
extra_body: Body | None = None,
855-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
856+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
856857
) -> ListBucketsResponse:
857858
"""List all Buckets."""
858859
extra_headers = {"Accept": "application/xml", **(extra_headers or {})}
@@ -868,13 +869,13 @@ def list_objects(
868869
self,
869870
bucket_name: str,
870871
*,
871-
list_type: Literal[2] | NotGiven = NOT_GIVEN,
872+
list_type: Literal[2] | Omit = omit,
872873
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
873874
# The extra values given here take precedence over values defined on the client or passed to this method.
874875
extra_headers: Headers | None = None,
875876
extra_query: Query | None = None,
876877
extra_body: Body | None = None,
877-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
878+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
878879
) -> ListObjectsResponse:
879880
"""
880881
List all objects contained in a given bucket.
@@ -909,14 +910,14 @@ def put_object(
909910
*,
910911
bucket_name: str,
911912
body: FileTypes,
912-
part_number: str | NotGiven = NOT_GIVEN,
913-
upload_id: str | NotGiven = NOT_GIVEN,
913+
part_number: str | Omit = omit,
914+
upload_id: str | Omit = omit,
914915
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
915916
# The extra values given here take precedence over values defined on the client or passed to this method.
916917
extra_headers: Headers | None = None,
917918
extra_query: Query | None = None,
918919
extra_body: Body | None = None,
919-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
920+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
920921
) -> None:
921922
"""
922923
Add an object to a bucket.
@@ -1149,7 +1150,7 @@ def __init__(
11491150
*,
11501151
api_key: str | None = None,
11511152
base_url: str | httpx.URL | None = None,
1152-
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
1153+
timeout: float | Timeout | None | NotGiven = not_given,
11531154
max_retries: int = DEFAULT_MAX_RETRIES,
11541155
default_headers: Mapping[str, str] | None = None,
11551156
default_query: Mapping[str, object] | None = None,
@@ -1384,9 +1385,9 @@ def copy(
13841385
*,
13851386
api_key: str | None = None,
13861387
base_url: str | httpx.URL | None = None,
1387-
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1388+
timeout: float | Timeout | None | NotGiven = not_given,
13881389
http_client: httpx.AsyncClient | None = None,
1389-
max_retries: int | NotGiven = NOT_GIVEN,
1390+
max_retries: int | NotGiven = not_given,
13901391
default_headers: Mapping[str, str] | None = None,
13911392
set_default_headers: Mapping[str, str] | None = None,
13921393
default_query: Mapping[str, object] | None = None,
@@ -1434,13 +1435,13 @@ async def create_bucket(
14341435
self,
14351436
bucket_name: str,
14361437
*,
1437-
location_constraint: str | NotGiven = NOT_GIVEN,
1438+
location_constraint: str | Omit = omit,
14381439
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
14391440
# The extra values given here take precedence over values defined on the client or passed to this method.
14401441
extra_headers: Headers | None = None,
14411442
extra_query: Query | None = None,
14421443
extra_body: Body | None = None,
1443-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1444+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
14441445
) -> None:
14451446
"""
14461447
Create a bucket.
@@ -1477,7 +1478,7 @@ async def delete_bucket(
14771478
extra_headers: Headers | None = None,
14781479
extra_query: Query | None = None,
14791480
extra_body: Body | None = None,
1480-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1481+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
14811482
) -> None:
14821483
"""Deletes a bucket.
14831484
@@ -1513,7 +1514,7 @@ async def delete_object(
15131514
extra_headers: Headers | None = None,
15141515
extra_query: Query | None = None,
15151516
extra_body: Body | None = None,
1516-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1517+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
15171518
) -> None:
15181519
"""
15191520
Delete an object from a given bucket.
@@ -1551,7 +1552,7 @@ async def delete_objects(
15511552
extra_headers: Headers | None = None,
15521553
extra_query: Query | None = None,
15531554
extra_body: Body | None = None,
1554-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1555+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
15551556
) -> object:
15561557
"""
15571558
Deletes one or multiple objects from a given bucket.
@@ -1588,13 +1589,13 @@ async def get_object(
15881589
object_name: str,
15891590
*,
15901591
bucket_name: str,
1591-
upload_id: str | NotGiven = NOT_GIVEN,
1592+
upload_id: str | Omit = omit,
15921593
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
15931594
# The extra values given here take precedence over values defined on the client or passed to this method.
15941595
extra_headers: Headers | None = None,
15951596
extra_query: Query | None = None,
15961597
extra_body: Body | None = None,
1597-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1598+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
15981599
) -> AsyncBinaryAPIResponse:
15991600
"""
16001601
Retrieves an object from a given bucket.
@@ -1635,7 +1636,7 @@ async def list_buckets(
16351636
extra_headers: Headers | None = None,
16361637
extra_query: Query | None = None,
16371638
extra_body: Body | None = None,
1638-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1639+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
16391640
) -> ListBucketsResponse:
16401641
"""List all Buckets."""
16411642
extra_headers = {"Accept": "application/xml", **(extra_headers or {})}
@@ -1651,13 +1652,13 @@ async def list_objects(
16511652
self,
16521653
bucket_name: str,
16531654
*,
1654-
list_type: Literal[2] | NotGiven = NOT_GIVEN,
1655+
list_type: Literal[2] | Omit = omit,
16551656
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
16561657
# The extra values given here take precedence over values defined on the client or passed to this method.
16571658
extra_headers: Headers | None = None,
16581659
extra_query: Query | None = None,
16591660
extra_body: Body | None = None,
1660-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1661+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
16611662
) -> ListObjectsResponse:
16621663
"""
16631664
List all objects contained in a given bucket.
@@ -1694,14 +1695,14 @@ async def put_object(
16941695
*,
16951696
bucket_name: str,
16961697
body: FileTypes,
1697-
part_number: str | NotGiven = NOT_GIVEN,
1698-
upload_id: str | NotGiven = NOT_GIVEN,
1698+
part_number: str | Omit = omit,
1699+
upload_id: str | Omit = omit,
16991700
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
17001701
# The extra values given here take precedence over values defined on the client or passed to this method.
17011702
extra_headers: Headers | None = None,
17021703
extra_query: Query | None = None,
17031704
extra_body: Body | None = None,
1704-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1705+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
17051706
) -> None:
17061707
"""
17071708
Add an object to a bucket.

src/telnyx/_qs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from urllib.parse import parse_qs, urlencode
55
from typing_extensions import Literal, get_args
66

7-
from ._types import NOT_GIVEN, NotGiven, NotGivenOr
7+
from ._types import NotGiven, not_given
88
from ._utils import flatten
99

1010
_T = TypeVar("_T")
@@ -41,8 +41,8 @@ def stringify(
4141
self,
4242
params: Params,
4343
*,
44-
array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
45-
nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
44+
array_format: ArrayFormat | NotGiven = not_given,
45+
nested_format: NestedFormat | NotGiven = not_given,
4646
) -> str:
4747
return urlencode(
4848
self.stringify_items(
@@ -56,8 +56,8 @@ def stringify_items(
5656
self,
5757
params: Params,
5858
*,
59-
array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
60-
nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
59+
array_format: ArrayFormat | NotGiven = not_given,
60+
nested_format: NestedFormat | NotGiven = not_given,
6161
) -> list[tuple[str, str]]:
6262
opts = Options(
6363
qs=self,
@@ -143,8 +143,8 @@ def __init__(
143143
self,
144144
qs: Querystring = _qs,
145145
*,
146-
array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
147-
nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
146+
array_format: ArrayFormat | NotGiven = not_given,
147+
nested_format: NestedFormat | NotGiven = not_given,
148148
) -> None:
149149
self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
150150
self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format

0 commit comments

Comments
 (0)