Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.8.4"
".": "1.8.5"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.8.5 (2025-05-15)

Full Changelog: [v1.8.4...v1.8.5](https://github.com/OneBusAway/python-sdk/compare/v1.8.4...v1.8.5)

### Chores

* **internal:** codegen related update ([#288](https://github.com/OneBusAway/python-sdk/issues/288)) ([d301a0c](https://github.com/OneBusAway/python-sdk/commit/d301a0cf24104ff0d791046c99093f3c47365bf3))

## 1.8.4 (2025-03-27)

Full Changelog: [v1.8.3...v1.8.4](https://github.com/OneBusAway/python-sdk/compare/v1.8.3...v1.8.4)
Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ client = AsyncOnebusawaySDK(
api_key=os.environ.get("ONEBUSAWAY_API_KEY"), # This is the default and can be omitted
)


async def main() -> None:
current_time = await client.current_time.retrieve()

current_time = await client.current_time.retrieve()

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

# Or, configure per-request:
client.with_options(max_retries=5).current_time.retrieve()
client.with_options(max_retries = 5).current_time.retrieve()
```

### Timeouts
Expand All @@ -155,7 +153,7 @@ client = OnebusawaySDK(
)

# Override per-request:
client.with_options(timeout=5.0).current_time.retrieve()
client.with_options(timeout = 5.0).current_time.retrieve()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -214,11 +212,11 @@ The above interface eagerly reads the full response body when you make the reque
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.

```python
with client.current_time.with_streaming_response.retrieve() as response:
print(response.headers.get("X-My-Header"))
with client.current_time.with_streaming_response.retrieve() as response :
print(response.headers.get('X-My-Header'))

for line in response.iter_lines():
print(line)
print(line)
```

The context manager is required so that the response will reliably be closed.
Expand Down Expand Up @@ -272,10 +270,7 @@ from onebusaway import OnebusawaySDK, DefaultHttpxClient
client = OnebusawaySDK(
# Or use the `ONEBUSAWAY_SDK_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),
)
```

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "onebusaway"
version = "1.8.4"
version = "1.8.5"
description = "The official Python library for the onebusaway-sdk API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via onebusaway
# via sdk-pythonpackagename
argcomplete==3.1.2
# via nox
certifi==2023.7.22
Expand All @@ -26,7 +26,7 @@ dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
# via onebusaway
# via sdk-pythonpackagename
exceptiongroup==1.2.2
# via anyio
# via pytest
Expand All @@ -37,8 +37,8 @@ h11==0.14.0
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via onebusaway
# via respx
# via sdk-pythonpackagename
idna==3.4
# via anyio
# via httpx
Expand All @@ -64,7 +64,7 @@ platformdirs==3.11.0
pluggy==1.5.0
# via pytest
pydantic==2.10.3
# via onebusaway
# via sdk-pythonpackagename
pydantic-core==2.27.1
# via pydantic
pygments==2.18.0
Expand All @@ -86,18 +86,18 @@ six==1.16.0
# via python-dateutil
sniffio==1.3.0
# via anyio
# via onebusaway
# via sdk-pythonpackagename
time-machine==2.9.0
tomli==2.0.2
# via mypy
# via pytest
typing-extensions==4.12.2
# via anyio
# via mypy
# via onebusaway
# via pydantic
# via pydantic-core
# via pyright
# via sdk-pythonpackagename
virtualenv==20.24.5
# via nox
zipp==3.17.0
Expand Down
12 changes: 6 additions & 6 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via onebusaway
# via sdk-pythonpackagename
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via onebusaway
# via sdk-pythonpackagename
exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via onebusaway
# via sdk-pythonpackagename
idna==3.4
# via anyio
# via httpx
pydantic==2.10.3
# via onebusaway
# via sdk-pythonpackagename
pydantic-core==2.27.1
# via pydantic
sniffio==1.3.0
# via anyio
# via onebusaway
# via sdk-pythonpackagename
typing-extensions==4.12.2
# via anyio
# via onebusaway
# via pydantic
# via pydantic-core
# via sdk-pythonpackagename
4 changes: 2 additions & 2 deletions scripts/utils/ruffen-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str:
with _collect_error(match):
code = format_code_block(code)
code = textwrap.indent(code, match["indent"])
return f"{match['before']}{code}{match['after']}"
return f'{match["before"]}{code}{match["after"]}'

def _pycon_match(match: Match[str]) -> str:
code = ""
Expand Down Expand Up @@ -97,7 +97,7 @@ def finish_fragment() -> None:
def _md_pycon_match(match: Match[str]) -> str:
code = _pycon_match(match)
code = textwrap.indent(code, match["indent"])
return f"{match['before']}{code}{match['after']}"
return f'{match["before"]}{code}{match["after"]}'

src = MD_RE.sub(_md_match, src)
src = MD_PYCON_RE.sub(_md_pycon_match, src)
Expand Down
45 changes: 3 additions & 42 deletions src/onebusaway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,7 @@
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__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",
]
__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"]

_setup_logging()

Expand All @@ -88,7 +49,7 @@
for __name in __all__:
if not __name.startswith("__"):
try:
__locals[__name].__module__ = "onebusaway"
__locals[__name].__module__ = "onebusaway"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
pass
11 changes: 8 additions & 3 deletions src/onebusaway/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _set_private_attributes(
model: Type[_T],
options: FinalRequestOptions,
) -> None:
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
if PYDANTIC_V2 and getattr(self, '__pydantic_private__', None) is None:
self.__pydantic_private__ = {}

self._model = model
Expand Down Expand Up @@ -291,7 +291,7 @@ def _set_private_attributes(
client: AsyncAPIClient,
options: FinalRequestOptions,
) -> None:
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
if PYDANTIC_V2 and getattr(self, '__pydantic_private__', None) is None:
self.__pydantic_private__ = {}

self._model = model
Expand Down Expand Up @@ -608,7 +608,7 @@ def default_headers(self) -> dict[str, str | Omit]:
"Accept": "application/json",
"Content-Type": "application/json",
"User-Agent": self.user_agent,
**self.platform_headers(),
**self.platform_headers(),
**self.auth_headers,
**self._custom_headers,
}
Expand Down Expand Up @@ -994,6 +994,7 @@ def _request(
response.reason_phrase,
response.headers,
)


try:
response.raise_for_status()
Expand Down Expand Up @@ -1069,6 +1070,8 @@ def _process_response(
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
retries_taken: int = 0,
) -> ResponseT:


origin = get_origin(cast_to) or cast_to

if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
Expand Down Expand Up @@ -1592,6 +1595,8 @@ async def _process_response(
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
retries_taken: int = 0,
) -> ResponseT:


origin = get_origin(cast_to) or cast_to

if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
Expand Down
Loading