Skip to content

Commit 4b14ec2

Browse files
committed
chore: configure new SDK language
1 parent 20c1a9c commit 4b14ec2

File tree

89 files changed

+2284
-1307
lines changed

Some content is hidden

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

89 files changed

+2284
-1307
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
33

44
USER vscode
55

6-
RUN curl -sSf https://rye-up.com/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash
6+
RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash
77
ENV PATH=/home/vscode/.rye/shims:$PATH
88

99
RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc

.github/workflows/ci.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,35 @@ jobs:
1818

1919
- name: Install Rye
2020
run: |
21-
curl -sSf https://rye-up.com/get | bash
21+
curl -sSf https://rye.astral.sh/get | bash
2222
echo "$HOME/.rye/shims" >> $GITHUB_PATH
2323
env:
2424
RYE_VERSION: 0.24.0
25-
RYE_INSTALL_OPTION: "--yes"
25+
RYE_INSTALL_OPTION: '--yes'
2626

2727
- name: Install dependencies
28-
run: |
29-
rye sync --all-features
28+
run: rye sync --all-features
3029

31-
- name: Run ruff
32-
run: |
33-
rye run check:ruff
30+
- name: Run lints
31+
run: ./scripts/lint
32+
test:
33+
name: test
34+
runs-on: ubuntu-latest
3435

35-
- name: Run type checking
36-
run: |
37-
rye run typecheck
36+
steps:
37+
- uses: actions/checkout@v4
3838

39-
- name: Ensure importable
39+
- name: Install Rye
4040
run: |
41-
rye run python -c 'import open_transit'
41+
curl -sSf https://rye.astral.sh/get | bash
42+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
43+
env:
44+
RYE_VERSION: 0.24.0
45+
RYE_INSTALL_OPTION: '--yes'
46+
47+
- name: Bootstrap
48+
run: ./scripts/bootstrap
49+
50+
- name: Run tests
51+
run: ./scripts/test
52+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dist
1212
.env
1313
.envrc
1414
codegen.log
15+
Brewfile.lock.json

.stats.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
configured_endpoints: 5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-968a191603d7f019c6df1700eb3973fcb80eb33b9a8f90ed4b467f4d99cbd1f3.yml

Brewfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew "rye"
2+

CONTRIBUTING.md

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

33
### With Rye
44

5-
We use [Rye](https://rye-up.com/) to manage dependencies so we highly recommend [installing it](https://rye-up.com/guide/installation/) as it will automatically provision a Python environment with the expected Python version.
5+
We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version.
66

77
After installing Rye, you'll just have to run this command:
88

@@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
3232
## Modifying/Adding code
3333

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

3737
## Adding and running examples
3838

@@ -59,7 +59,7 @@ If you’d like to use the repository from source, you can either install from g
5959
To install via git:
6060

6161
```bash
62-
pip install git+ssh://git@github.com/stainless-sdks/TEMP_open-transit-python.git
62+
pip install git+ssh://git@github.com/stainless-sdks/open-transit-python.git
6363
```
6464

6565
Alternatively, you can build from source and install the wheel file:
@@ -117,7 +117,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
117117

118118
### Publish with a GitHub workflow
119119

120-
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/TEMP_open-transit-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
120+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/open-transit-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
121121

122122
### Publish manually
123123

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2024 Open Transit
189+
Copyright 2024 One Bus Away
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Open Transit Python API library
1+
# One Bus Away Python API library
22

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

5-
The Open Transit Python library provides convenient access to the Open Transit REST API from any Python 3.7+
5+
The One Bus Away Python library provides convenient access to the One Bus Away REST API from any Python 3.7+
66
application. The library includes type definitions for all request params and response fields,
77
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
88

@@ -15,35 +15,53 @@ The REST API documentation can be found [on docs.open-transit.com](https://docs.
1515
## Installation
1616

1717
```sh
18-
# install from PyPI
19-
pip install --pre TEMP_open-transit
18+
# install from this staging repo
19+
pip install git+ssh://git@github.com/stainless-sdks/open-transit-python.git
2020
```
2121

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

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

2629
```python
27-
from open_transit import OpenTransit
30+
import os
31+
from onebusaway import OneBusAway
2832

29-
client = OpenTransit()
33+
client = OneBusAway(
34+
# This is the default and can be omitted
35+
api_key=os.environ.get("OPEN_TRANSIT_API_KEY"),
36+
)
3037

31-
response = client.agencies_with_coverage.list()
38+
agencies_with_coverage_retrieve_response = client.agencies_with_coverage.retrieve()
39+
print(agencies_with_coverage_retrieve_response.code)
3240
```
3341

42+
While you can provide an `api_key` keyword argument,
43+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
44+
to add `OPEN_TRANSIT_API_KEY="My API Key"` to your `.env` file
45+
so that your API Key is not stored in source control.
46+
3447
## Async usage
3548

36-
Simply import `AsyncOpenTransit` instead of `OpenTransit` and use `await` with each API call:
49+
Simply import `AsyncOneBusAway` instead of `OneBusAway` and use `await` with each API call:
3750

3851
```python
52+
import os
3953
import asyncio
40-
from open_transit import AsyncOpenTransit
54+
from onebusaway import AsyncOneBusAway
4155

42-
client = AsyncOpenTransit()
56+
client = AsyncOneBusAway(
57+
# This is the default and can be omitted
58+
api_key=os.environ.get("OPEN_TRANSIT_API_KEY"),
59+
)
4360

4461

4562
async def main() -> None:
46-
response = await client.agencies_with_coverage.list()
63+
agencies_with_coverage_retrieve_response = await client.agencies_with_coverage.retrieve()
64+
print(agencies_with_coverage_retrieve_response.code)
4765

4866

4967
asyncio.run(main())
@@ -53,36 +71,36 @@ Functionality between the synchronous and asynchronous clients is otherwise iden
5371

5472
## Using types
5573

56-
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev), which provide helper methods for things like:
74+
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
5775

58-
- Serializing back into JSON, `model.model_dump_json(indent=2, exclude_unset=True)`
59-
- Converting to a dictionary, `model.model_dump(exclude_unset=True)`
76+
- Serializing back into JSON, `model.to_json()`
77+
- Converting to a dictionary, `model.to_dict()`
6078

6179
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
6280

6381
## Handling errors
6482

65-
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.
83+
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.
6684

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

70-
All errors inherit from `open_transit.APIError`.
88+
All errors inherit from `onebusaway.APIError`.
7189

7290
```python
73-
import open_transit
74-
from open_transit import OpenTransit
91+
import onebusaway
92+
from onebusaway import OneBusAway
7593

76-
client = OpenTransit()
94+
client = OneBusAway()
7795

7896
try:
79-
client.agencies_with_coverage.list()
80-
except open_transit.APIConnectionError as e:
97+
client.agencies_with_coverage.retrieve()
98+
except onebusaway.APIConnectionError as e:
8199
print("The server could not be reached")
82100
print(e.__cause__) # an underlying Exception, likely raised within httpx.
83-
except open_transit.RateLimitError as e:
101+
except onebusaway.RateLimitError as e:
84102
print("A 429 status code was received; we should back off a bit.")
85-
except open_transit.APIStatusError as e:
103+
except onebusaway.APIStatusError as e:
86104
print("Another non-200-range status code was received")
87105
print(e.status_code)
88106
print(e.response)
@@ -110,16 +128,16 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
110128
You can use the `max_retries` option to configure or disable retry settings:
111129

112130
```python
113-
from open_transit import OpenTransit
131+
from onebusaway import OneBusAway
114132

115133
# Configure the default for all requests:
116-
client = OpenTransit(
134+
client = OneBusAway(
117135
# default is 2
118136
max_retries=0,
119137
)
120138

121139
# Or, configure per-request:
122-
client.with_options(max_retries=5).agencies_with_coverage.list()
140+
client.with_options(max_retries=5).agencies_with_coverage.retrieve()
123141
```
124142

125143
### Timeouts
@@ -128,21 +146,21 @@ By default requests time out after 1 minute. You can configure this with a `time
128146
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
129147

130148
```python
131-
from open_transit import OpenTransit
149+
from onebusaway import OneBusAway
132150

133151
# Configure the default for all requests:
134-
client = OpenTransit(
152+
client = OneBusAway(
135153
# 20 seconds (default is 1 minute)
136154
timeout=20.0,
137155
)
138156

139157
# More granular control:
140-
client = OpenTransit(
158+
client = OneBusAway(
141159
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
142160
)
143161

144162
# Override per-request:
145-
client.with_options(timeout=5 * 1000).agencies_with_coverage.list()
163+
client.with_options(timeout=5.0).agencies_with_coverage.retrieve()
146164
```
147165

148166
On timeout, an `APITimeoutError` is thrown.
@@ -155,10 +173,10 @@ Note that requests that time out are [retried twice by default](#retries).
155173

156174
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
157175

158-
You can enable logging by setting the environment variable `OPEN_TRANSIT_LOG` to `debug`.
176+
You can enable logging by setting the environment variable `ONE_BUS_AWAY_LOG` to `debug`.
159177

160178
```shell
161-
$ export OPEN_TRANSIT_LOG=debug
179+
$ export ONE_BUS_AWAY_LOG=debug
162180
```
163181

164182
### How to tell whether `None` means `null` or missing
@@ -178,19 +196,19 @@ if response.my_field is None:
178196
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
179197

180198
```py
181-
from open_transit import OpenTransit
199+
from onebusaway import OneBusAway
182200

183-
client = OpenTransit()
184-
response = client.agencies_with_coverage.with_raw_response.list()
201+
client = OneBusAway()
202+
response = client.agencies_with_coverage.with_raw_response.retrieve()
185203
print(response.headers.get('X-My-Header'))
186204

187-
agencies_with_coverage = response.parse() # get the object that `agencies_with_coverage.list()` would have returned
188-
print(agencies_with_coverage)
205+
agencies_with_coverage = response.parse() # get the object that `agencies_with_coverage.retrieve()` would have returned
206+
print(agencies_with_coverage.code)
189207
```
190208

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

193-
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/tree/main/src/open_transit/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
211+
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.
194212

195213
#### `.with_streaming_response`
196214

@@ -199,7 +217,7 @@ The above interface eagerly reads the full response body when you make the reque
199217
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.
200218

201219
```python
202-
with client.agencies_with_coverage.with_streaming_response.list() as response:
220+
with client.agencies_with_coverage.with_streaming_response.retrieve() as response:
203221
print(response.headers.get("X-My-Header"))
204222

205223
for line in response.iter_lines():
@@ -210,7 +228,7 @@ The context manager is required so that the response will reliably be closed.
210228

211229
### Making custom/undocumented requests
212230

213-
This library is typed for convenient access the documented API.
231+
This library is typed for convenient access to the documented API.
214232

215233
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
216234

@@ -252,10 +270,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
252270
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality
253271

254272
```python
255-
from open_transit import OpenTransit, DefaultHttpxClient
273+
from onebusaway import OneBusAway, DefaultHttpxClient
256274

257-
client = OpenTransit(
258-
# Or use the `OPEN_TRANSIT_BASE_URL` env var
275+
client = OneBusAway(
276+
# Or use the `ONE_BUS_AWAY_BASE_URL` env var
259277
base_url="http://my.test.server.example.com:8083",
260278
http_client=DefaultHttpxClient(
261279
proxies="http://my.test.proxy.example.com",
@@ -278,7 +296,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
278296

279297
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
280298

281-
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/TEMP_open-transit-python/issues) with questions, bugs, or suggestions.
299+
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/open-transit-python/issues) with questions, bugs, or suggestions.
282300

283301
## Requirements
284302

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Security Policy
2+
3+
## Reporting Security Issues
4+
5+
This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
6+
7+
To report a security issue, please contact the Stainless team at security@stainlessapi.com.
8+
9+
## Responsible Disclosure
10+
11+
We appreciate the efforts of security researchers and individuals who help us maintain the security of
12+
SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible
13+
disclosure practices by allowing us a reasonable amount of time to investigate and address the issue
14+
before making any information public.
15+
16+
## Reporting Non-SDK Related Security Issues
17+
18+
If you encounter security issues that are not directly related to SDKs but pertain to the services
19+
or products provided by One Bus Away please follow the respective company's security reporting guidelines.
20+
21+
### One Bus Away Terms and Policies
22+
23+
Please contact dev-feedback@open-transit.com for any questions or concerns regarding security of our services.
24+
25+
---
26+
27+
Thank you for helping us keep the SDKs and systems they interact with secure.

0 commit comments

Comments
 (0)