Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 19, 2024
1 parent 3beb328 commit 84da952
Show file tree
Hide file tree
Showing 69 changed files with 118 additions and 120 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
## Modifying/Adding code

Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
`src/open_transit/lib/` and `examples/` directories are exceptions and will never be overridden.
`src/onebusaway/lib/` and `examples/` directories are exceptions and will never be overridden.

## Adding and running examples

Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# One Bus Away Python API library

[![PyPI version](https://img.shields.io/pypi/v/open-transit.svg)](https://pypi.org/project/open-transit/)
[![PyPI version](https://img.shields.io/pypi/v/onebusaway.svg)](https://pypi.org/project/onebusaway/)

The One Bus Away Python library provides convenient access to the One Bus Away REST API from any Python 3.7+
application. The library includes type definitions for all request params and response fields,
Expand All @@ -20,15 +20,15 @@ pip install git+ssh://[email protected]/stainless-sdks/open-transit-python.git
```

> [!NOTE]
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre open-transit`
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre onebusaway`
## Usage

The full API of this library can be found in [api.md](api.md).

```python
import os
from open_transit import OneBusAway
from onebusaway import OneBusAway

client = OneBusAway(
# This is the default and can be omitted
Expand All @@ -50,7 +50,7 @@ Simply import `AsyncOneBusAway` instead of `OneBusAway` and use `await` with eac
```python
import os
import asyncio
from open_transit import AsyncOneBusAway
from onebusaway import AsyncOneBusAway

client = AsyncOneBusAway(
# This is the default and can be omitted
Expand Down Expand Up @@ -78,27 +78,27 @@ Typed requests and responses provide autocomplete and documentation within your

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `open_transit.APIConnectionError` is raised.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `onebusaway.APIConnectionError` is raised.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `open_transit.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `onebusaway.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `open_transit.APIError`.
All errors inherit from `onebusaway.APIError`.

```python
import open_transit
from open_transit import OneBusAway
import onebusaway
from onebusaway import OneBusAway

client = OneBusAway()

try:
client.current_time.retrieve()
except open_transit.APIConnectionError as e:
except onebusaway.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except open_transit.RateLimitError as e:
except onebusaway.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except open_transit.APIStatusError as e:
except onebusaway.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -126,7 +126,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from open_transit import OneBusAway
from onebusaway import OneBusAway

# Configure the default for all requests:
client = OneBusAway(
Expand All @@ -144,7 +144,7 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from open_transit import OneBusAway
from onebusaway import OneBusAway

# Configure the default for all requests:
client = OneBusAway(
Expand Down Expand Up @@ -194,7 +194,7 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from open_transit import OneBusAway
from onebusaway import OneBusAway

client = OneBusAway()
response = client.current_time.with_raw_response.retrieve()
Expand All @@ -204,9 +204,9 @@ current_time = response.parse() # get the object that `current_time.retrieve()`
print(current_time)
```

These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/open_transit/_response.py) object.
These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/onebusaway/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/open_transit/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/onebusaway/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -268,7 +268,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality

```python
from open_transit import OneBusAway, DefaultHttpxClient
from onebusaway import OneBusAway, DefaultHttpxClient

client = OneBusAway(
# Or use the `ONE_BUS_AWAY_BASE_URL` env var
Expand Down
26 changes: 13 additions & 13 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
# Shared Types

```python
from open_transit.types import ResponseWrapper
from onebusaway.types import ResponseWrapper
```

# AgenciesWithCoverage

Types:

```python
from open_transit.types import AgenciesWithCoverageListResponse
from onebusaway.types import AgenciesWithCoverageListResponse
```

Methods:

- <code title="get /api/where/agencies-with-coverage.json">client.agencies_with_coverage.<a href="./src/open_transit/resources/agencies_with_coverage.py">list</a>() -> <a href="./src/open_transit/types/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code>
- <code title="get /api/where/agencies-with-coverage.json">client.agencies_with_coverage.<a href="./src/onebusaway/resources/agencies_with_coverage.py">list</a>() -> <a href="./src/onebusaway/types/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code>

# Config

Types:

```python
from open_transit.types import ConfigRetrieveResponse
from onebusaway.types import ConfigRetrieveResponse
```

Methods:

- <code title="get /api/where/config.json">client.config.<a href="./src/open_transit/resources/config.py">retrieve</a>() -> <a href="./src/open_transit/types/config_retrieve_response.py">ConfigRetrieveResponse</a></code>
- <code title="get /api/where/config.json">client.config.<a href="./src/onebusaway/resources/config.py">retrieve</a>() -> <a href="./src/onebusaway/types/config_retrieve_response.py">ConfigRetrieveResponse</a></code>

# CurrentTime

Types:

```python
from open_transit.types import CurrentTimeRetrieveResponse
from onebusaway.types import CurrentTimeRetrieveResponse
```

Methods:

- <code title="get /api/where/current-time.json">client.current_time.<a href="./src/open_transit/resources/current_time.py">retrieve</a>() -> <a href="./src/open_transit/types/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code>
- <code title="get /api/where/current-time.json">client.current_time.<a href="./src/onebusaway/resources/current_time.py">retrieve</a>() -> <a href="./src/onebusaway/types/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code>

# StopsForLocation

Types:

```python
from open_transit.types import StopsForLocationListResponse
from onebusaway.types import StopsForLocationListResponse
```

Methods:

- <code title="get /api/where/stops-for-location.json">client.stops_for_location.<a href="./src/open_transit/resources/stops_for_location.py">list</a>(\*\*<a href="src/open_transit/types/stops_for_location_list_params.py">params</a>) -> <a href="./src/open_transit/types/stops_for_location_list_response.py">StopsForLocationListResponse</a></code>
- <code title="get /api/where/stops-for-location.json">client.stops_for_location.<a href="./src/onebusaway/resources/stops_for_location.py">list</a>(\*\*<a href="src/onebusaway/types/stops_for_location_list_params.py">params</a>) -> <a href="./src/onebusaway/types/stops_for_location_list_response.py">StopsForLocationListResponse</a></code>

# ArrivalAndDepartureForStop

Types:

```python
from open_transit.types import ArrivalAndDepartureForStopRetrieveResponse
from onebusaway.types import ArrivalAndDepartureForStopRetrieveResponse
```

Methods:

- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrival_and_departure_for_stop.<a href="./src/open_transit/resources/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/open_transit/types/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/open_transit/types/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code>
- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrival_and_departure_for_stop.<a href="./src/onebusaway/resources/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/onebusaway/types/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/onebusaway/types/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code>

# ArrivalsAndDeparturesForStop

Types:

```python
from open_transit.types import ArrivalsAndDeparturesForStopListResponse
from onebusaway.types import ArrivalsAndDeparturesForStopListResponse
```

Methods:

- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivals_and_departures_for_stop.<a href="./src/open_transit/resources/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/open_transit/types/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code>
- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivals_and_departures_for_stop.<a href="./src/onebusaway/resources/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/onebusaway/types/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code>
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
exclude = ^(src/open_transit/_files\.py|_dev/.*\.py)$
exclude = ^(src/onebusaway/_files\.py|_dev/.*\.py)$

strict_equality = True
implicit_reexport = True
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "open-transit"
name = "onebusaway"
version = "0.0.1-alpha.0"
description = "The official Python library for the OneBusAway API"
dynamic = ["readme"]
Expand Down Expand Up @@ -84,7 +84,7 @@ typecheck = { chain = [
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes open_transit --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes onebusaway --ignoreexternal"
"typecheck:mypy" = "mypy ."

[build-system]
Expand All @@ -97,7 +97,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/open_transit"]
packages = ["src/onebusaway"]

[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
Expand Down Expand Up @@ -187,7 +187,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["open_transit", "tests"]
known-first-party = ["onebusaway", "tests"]

[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
# via open-transit
# via onebusaway
argcomplete==3.1.2
# via nox
attrs==23.1.0
Expand All @@ -26,7 +26,7 @@ dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
# via open-transit
# via onebusaway
exceptiongroup==1.1.3
# via anyio
filelock==3.12.4
Expand All @@ -36,7 +36,7 @@ h11==0.14.0
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via open-transit
# via onebusaway
# via respx
idna==3.4
# via anyio
Expand All @@ -60,7 +60,7 @@ pluggy==1.3.0
py==1.11.0
# via pytest
pydantic==2.7.1
# via open-transit
# via onebusaway
pydantic-core==2.18.2
# via pydantic
pyright==1.1.364
Expand All @@ -80,14 +80,14 @@ six==1.16.0
sniffio==1.3.0
# via anyio
# via httpx
# via open-transit
# via onebusaway
time-machine==2.9.0
tomli==2.0.1
# via mypy
# via pytest
typing-extensions==4.8.0
# via mypy
# via open-transit
# via onebusaway
# via pydantic
# via pydantic-core
virtualenv==20.24.5
Expand Down
12 changes: 6 additions & 6 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
# via open-transit
# via onebusaway
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via open-transit
# via onebusaway
exceptiongroup==1.1.3
# via anyio
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via open-transit
# via onebusaway
idna==3.4
# via anyio
# via httpx
pydantic==2.7.1
# via open-transit
# via onebusaway
pydantic-core==2.18.2
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
# via open-transit
# via onebusaway
typing-extensions==4.8.0
# via open-transit
# via onebusaway
# via pydantic
# via pydantic-core
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo "==> Running lints"
rye run lint

echo "==> Making sure it imports"
rye run python -c 'import open_transit'
rye run python -c 'import onebusaway'

4 changes: 2 additions & 2 deletions src/open_transit/__init__.py → src/onebusaway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
# Update the __module__ attribute for exported symbols so that
# error messages point to this module instead of the module
# it was originally defined in, e.g.
# open_transit._exceptions.NotFoundError -> open_transit.NotFoundError
# onebusaway._exceptions.NotFoundError -> onebusaway.NotFoundError
__locals = locals()
for __name in __all__:
if not __name.startswith("__"):
try:
__locals[__name].__module__ = "open_transit"
__locals[__name].__module__ = "onebusaway"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def __init__(

if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
raise TypeError(
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `open-transit.DEFAULT_MAX_RETRIES`"
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `onebusaway.DEFAULT_MAX_RETRIES`"
)

def _enforce_trailing_slash(self, url: URL) -> URL:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 84da952

Please sign in to comment.