Skip to content

Commit d301a0c

Browse files
chore(internal): codegen related update (#288)
1 parent ccadbb1 commit d301a0c

File tree

125 files changed

+3805
-5041
lines changed

Some content is hidden

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

125 files changed

+3805
-5041
lines changed

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ client = AsyncOnebusawaySDK(
5454
api_key=os.environ.get("ONEBUSAWAY_API_KEY"), # This is the default and can be omitted
5555
)
5656

57-
5857
async def main() -> None:
59-
current_time = await client.current_time.retrieve()
60-
58+
current_time = await client.current_time.retrieve()
6159

6260
asyncio.run(main())
6361
```
@@ -92,7 +90,7 @@ try:
9290
client.current_time.retrieve()
9391
except onebusaway.APIConnectionError as e:
9492
print("The server could not be reached")
95-
print(e.__cause__) # an underlying Exception, likely raised within httpx.
93+
print(e.__cause__) # an underlying Exception, likely raised within httpx.
9694
except onebusaway.RateLimitError as e:
9795
print("A 429 status code was received; we should back off a bit.")
9896
except onebusaway.APIStatusError as e:
@@ -132,7 +130,7 @@ client = OnebusawaySDK(
132130
)
133131

134132
# Or, configure per-request:
135-
client.with_options(max_retries=5).current_time.retrieve()
133+
client.with_options(max_retries = 5).current_time.retrieve()
136134
```
137135

138136
### Timeouts
@@ -155,7 +153,7 @@ client = OnebusawaySDK(
155153
)
156154

157155
# Override per-request:
158-
client.with_options(timeout=5.0).current_time.retrieve()
156+
client.with_options(timeout = 5.0).current_time.retrieve()
159157
```
160158

161159
On timeout, an `APITimeoutError` is thrown.
@@ -214,11 +212,11 @@ The above interface eagerly reads the full response body when you make the reque
214212
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
215213

216214
```python
217-
with client.current_time.with_streaming_response.retrieve() as response:
218-
print(response.headers.get("X-My-Header"))
215+
with client.current_time.with_streaming_response.retrieve() as response :
216+
print(response.headers.get('X-My-Header'))
219217

220218
for line in response.iter_lines():
221-
print(line)
219+
print(line)
222220
```
223221

224222
The context manager is required so that the response will reliably be closed.
@@ -272,10 +270,7 @@ from onebusaway import OnebusawaySDK, DefaultHttpxClient
272270
client = OnebusawaySDK(
273271
# Or use the `ONEBUSAWAY_SDK_BASE_URL` env var
274272
base_url="http://my.test.server.example.com:8083",
275-
http_client=DefaultHttpxClient(
276-
proxy="http://my.test.proxy.example.com",
277-
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
278-
),
273+
http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),
279274
)
280275
```
281276

requirements-dev.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ annotated-types==0.6.0
1414
# via pydantic
1515
anyio==4.4.0
1616
# via httpx
17-
# via onebusaway
17+
# via sdk-pythonpackagename
1818
argcomplete==3.1.2
1919
# via nox
2020
certifi==2023.7.22
@@ -26,7 +26,7 @@ dirty-equals==0.6.0
2626
distlib==0.3.7
2727
# via virtualenv
2828
distro==1.8.0
29-
# via onebusaway
29+
# via sdk-pythonpackagename
3030
exceptiongroup==1.2.2
3131
# via anyio
3232
# via pytest
@@ -37,8 +37,8 @@ h11==0.14.0
3737
httpcore==1.0.2
3838
# via httpx
3939
httpx==0.28.1
40-
# via onebusaway
4140
# via respx
41+
# via sdk-pythonpackagename
4242
idna==3.4
4343
# via anyio
4444
# via httpx
@@ -64,7 +64,7 @@ platformdirs==3.11.0
6464
pluggy==1.5.0
6565
# via pytest
6666
pydantic==2.10.3
67-
# via onebusaway
67+
# via sdk-pythonpackagename
6868
pydantic-core==2.27.1
6969
# via pydantic
7070
pygments==2.18.0
@@ -86,18 +86,18 @@ six==1.16.0
8686
# via python-dateutil
8787
sniffio==1.3.0
8888
# via anyio
89-
# via onebusaway
89+
# via sdk-pythonpackagename
9090
time-machine==2.9.0
9191
tomli==2.0.2
9292
# via mypy
9393
# via pytest
9494
typing-extensions==4.12.2
9595
# via anyio
9696
# via mypy
97-
# via onebusaway
9897
# via pydantic
9998
# via pydantic-core
10099
# via pyright
100+
# via sdk-pythonpackagename
101101
virtualenv==20.24.5
102102
# via nox
103103
zipp==3.17.0

requirements.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@ annotated-types==0.6.0
1414
# via pydantic
1515
anyio==4.4.0
1616
# via httpx
17-
# via onebusaway
17+
# via sdk-pythonpackagename
1818
certifi==2023.7.22
1919
# via httpcore
2020
# via httpx
2121
distro==1.8.0
22-
# via onebusaway
22+
# via sdk-pythonpackagename
2323
exceptiongroup==1.2.2
2424
# via anyio
2525
h11==0.14.0
2626
# via httpcore
2727
httpcore==1.0.2
2828
# via httpx
2929
httpx==0.28.1
30-
# via onebusaway
30+
# via sdk-pythonpackagename
3131
idna==3.4
3232
# via anyio
3333
# via httpx
3434
pydantic==2.10.3
35-
# via onebusaway
35+
# via sdk-pythonpackagename
3636
pydantic-core==2.27.1
3737
# via pydantic
3838
sniffio==1.3.0
3939
# via anyio
40-
# via onebusaway
40+
# via sdk-pythonpackagename
4141
typing-extensions==4.12.2
4242
# via anyio
43-
# via onebusaway
4443
# via pydantic
4544
# via pydantic-core
45+
# via sdk-pythonpackagename

scripts/utils/ruffen-docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str:
4747
with _collect_error(match):
4848
code = format_code_block(code)
4949
code = textwrap.indent(code, match["indent"])
50-
return f"{match['before']}{code}{match['after']}"
50+
return f'{match["before"]}{code}{match["after"]}'
5151

5252
def _pycon_match(match: Match[str]) -> str:
5353
code = ""
@@ -97,7 +97,7 @@ def finish_fragment() -> None:
9797
def _md_pycon_match(match: Match[str]) -> str:
9898
code = _pycon_match(match)
9999
code = textwrap.indent(code, match["indent"])
100-
return f"{match['before']}{code}{match['after']}"
100+
return f'{match["before"]}{code}{match["after"]}'
101101

102102
src = MD_RE.sub(_md_match, src)
103103
src = MD_PYCON_RE.sub(_md_pycon_match, src)

src/onebusaway/__init__.py

Lines changed: 10 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,18 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
from . import types
4-
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
4+
from ._version import __version__, __title__
5+
from ._client import Timeout,Transport,RequestOptions,Client,AsyncClient,Stream,AsyncStream,OnebusawaySDK,AsyncOnebusawaySDK
6+
from ._exceptions import OnebusawaySDKError,APIError,APIStatusError,APITimeoutError,APIConnectionError,APIResponseValidationError,BadRequestError,AuthenticationError,PermissionDeniedError,NotFoundError,ConflictError,UnprocessableEntityError,RateLimitError,InternalServerError
7+
from ._types import NoneType,Transport,ProxiesTypes,NotGiven,NOT_GIVEN,Omit
58
from ._utils import file_from_path
6-
from ._client import (
7-
Client,
8-
Stream,
9-
Timeout,
10-
Transport,
11-
AsyncClient,
12-
AsyncStream,
13-
OnebusawaySDK,
14-
RequestOptions,
15-
AsyncOnebusawaySDK,
16-
)
179
from ._models import BaseModel
18-
from ._version import __title__, __version__
19-
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
20-
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
21-
from ._exceptions import (
22-
APIError,
23-
ConflictError,
24-
NotFoundError,
25-
APIStatusError,
26-
RateLimitError,
27-
APITimeoutError,
28-
BadRequestError,
29-
APIConnectionError,
30-
OnebusawaySDKError,
31-
AuthenticationError,
32-
InternalServerError,
33-
PermissionDeniedError,
34-
UnprocessableEntityError,
35-
APIResponseValidationError,
36-
)
37-
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
10+
from ._constants import DEFAULT_TIMEOUT,DEFAULT_MAX_RETRIES,DEFAULT_CONNECTION_LIMITS
11+
from ._base_client import DefaultHttpxClient,DefaultAsyncHttpxClient
3812
from ._utils._logs import setup_logging as _setup_logging
13+
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
3914

40-
__all__ = [
41-
"types",
42-
"__version__",
43-
"__title__",
44-
"NoneType",
45-
"Transport",
46-
"ProxiesTypes",
47-
"NotGiven",
48-
"NOT_GIVEN",
49-
"Omit",
50-
"OnebusawaySDKError",
51-
"APIError",
52-
"APIStatusError",
53-
"APITimeoutError",
54-
"APIConnectionError",
55-
"APIResponseValidationError",
56-
"BadRequestError",
57-
"AuthenticationError",
58-
"PermissionDeniedError",
59-
"NotFoundError",
60-
"ConflictError",
61-
"UnprocessableEntityError",
62-
"RateLimitError",
63-
"InternalServerError",
64-
"Timeout",
65-
"RequestOptions",
66-
"Client",
67-
"AsyncClient",
68-
"Stream",
69-
"AsyncStream",
70-
"OnebusawaySDK",
71-
"AsyncOnebusawaySDK",
72-
"file_from_path",
73-
"BaseModel",
74-
"DEFAULT_TIMEOUT",
75-
"DEFAULT_MAX_RETRIES",
76-
"DEFAULT_CONNECTION_LIMITS",
77-
"DefaultHttpxClient",
78-
"DefaultAsyncHttpxClient",
79-
]
15+
__all__ = ["types", "__version__", "__title__", "NoneType", "Transport", "ProxiesTypes", "NotGiven", "NOT_GIVEN", "Omit", "OnebusawaySDKError", "APIError", "APIStatusError", "APITimeoutError", "APIConnectionError", "APIResponseValidationError", "BadRequestError", "AuthenticationError", "PermissionDeniedError", "NotFoundError", "ConflictError", "UnprocessableEntityError", "RateLimitError", "InternalServerError", "Timeout", "RequestOptions", "Client", "AsyncClient", "Stream", "AsyncStream", "OnebusawaySDK", "AsyncOnebusawaySDK", "file_from_path", "BaseModel", "DEFAULT_TIMEOUT", "DEFAULT_MAX_RETRIES", "DEFAULT_CONNECTION_LIMITS", "DefaultHttpxClient", "DefaultAsyncHttpxClient"]
8016

8117
_setup_logging()
8218

@@ -88,7 +24,7 @@
8824
for __name in __all__:
8925
if not __name.startswith("__"):
9026
try:
91-
__locals[__name].__module__ = "onebusaway"
27+
setattr(__locals[__name], "__module__", "onebusaway")
9228
except (TypeError, AttributeError):
9329
# Some of our exported symbols are builtins which we can't set attributes for.
94-
pass
30+
pass

src/onebusaway/_base_client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import inspect
1010
import logging
1111
import platform
12+
import warnings
1213
import email.utils
1314
from types import TracebackType
1415
from random import random
@@ -83,6 +84,7 @@
8384
APIConnectionError,
8485
APIResponseValidationError,
8586
)
87+
from ._legacy_response import LegacyAPIResponse
8688

8789
log: logging.Logger = logging.getLogger(__name__)
8890

@@ -203,7 +205,7 @@ def _set_private_attributes(
203205
model: Type[_T],
204206
options: FinalRequestOptions,
205207
) -> None:
206-
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
208+
if PYDANTIC_V2 and getattr(self, '__pydantic_private__', None) is None:
207209
self.__pydantic_private__ = {}
208210

209211
self._model = model
@@ -291,7 +293,7 @@ def _set_private_attributes(
291293
client: AsyncAPIClient,
292294
options: FinalRequestOptions,
293295
) -> None:
294-
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
296+
if PYDANTIC_V2 and getattr(self, '__pydantic_private__', None) is None:
295297
self.__pydantic_private__ = {}
296298

297299
self._model = model
@@ -608,7 +610,7 @@ def default_headers(self) -> dict[str, str | Omit]:
608610
"Accept": "application/json",
609611
"Content-Type": "application/json",
610612
"User-Agent": self.user_agent,
611-
**self.platform_headers(),
613+
**self.platform_headers(),
612614
**self.auth_headers,
613615
**self._custom_headers,
614616
}
@@ -994,6 +996,7 @@ def _request(
994996
response.reason_phrase,
995997
response.headers,
996998
)
999+
9971000

9981001
try:
9991002
response.raise_for_status()
@@ -1069,6 +1072,8 @@ def _process_response(
10691072
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
10701073
retries_taken: int = 0,
10711074
) -> ResponseT:
1075+
1076+
10721077
origin = get_origin(cast_to) or cast_to
10731078

10741079
if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
@@ -1592,6 +1597,8 @@ async def _process_response(
15921597
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
15931598
retries_taken: int = 0,
15941599
) -> ResponseT:
1600+
1601+
15951602
origin = get_origin(cast_to) or cast_to
15961603

15971604
if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):

0 commit comments

Comments
 (0)