Skip to content

Commit d71b1a1

Browse files
authored
Merge pull request #3 from convox/pytypt
add py.type marker and GH actions
2 parents d8666da + 28b1a23 commit d71b1a1

5 files changed

Lines changed: 86 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: pip install -e ".[dev]"
25+
26+
- name: Lint
27+
run: ruff check .
28+
29+
- name: Format check
30+
run: ruff format --check .
31+
32+
- name: Type check
33+
run: mypy src/
34+
35+
- name: Unit tests
36+
run: pytest tests/ -v

.github/workflows/publish.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
id-token: write
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
21+
- name: Install build tools
22+
run: pip install hatch
23+
24+
- name: Build
25+
run: hatch build
26+
27+
- name: Publish to PyPI
28+
uses: pypa/gh-action-pypi-publish@release/v1

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ data = client.api.post("/apps/myapp/builds/import", content=tarball, timeout=600
251251

252252
## Streaming
253253

254-
The low-level `stream()` method returns the raw `httpx.Response` without
255-
checking for error status codes. This is intentional: streaming endpoints
256-
(logs, build output) may send partial data before an error occurs.
254+
The `stream()` method returns the raw `httpx.Response` without checking for
255+
error status codes. This is intentional: streaming endpoints (logs, build
256+
output) may send partial data before an error occurs.
257257

258258
```python
259-
response = client._http.stream("GET", "/apps/myapp/logs", params={"follow": "true"})
259+
response = client.stream("GET", "/apps/myapp/logs", params={"follow": "true"})
260260
try:
261261
if response.status_code >= 400:
262262
print(f"Error: {response.status_code}")

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ classifiers = [
2727
dependencies = [
2828
"httpx>=0.27,<1",
2929
"pydantic>=2.0,<3",
30+
"eval_type_backport>=0.2.0; python_version < '3.10'",
3031
]
3132

3233
[project.urls]

src/convox/client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ def from_cli_config(
130130
host, api_key = credentials_from_cli_config(rack=rack, config_path=config_path)
131131
return cls(host, api_key, rack=rack, retry=retry, timeout=timeout)
132132

133+
def stream(
134+
self,
135+
method: str,
136+
path: str,
137+
**kwargs: object,
138+
) -> object:
139+
"""Send a streaming request and return the raw ``httpx.Response``.
140+
141+
Unlike normal API calls, this does **not** raise on 4xx/5xx status
142+
codes. The caller must check ``response.status_code`` and call
143+
``response.close()`` when done.
144+
145+
This is intentional: streaming endpoints (logs, build output) may
146+
send partial data before an error occurs.
147+
"""
148+
return self._http.stream(method, path, **kwargs)
149+
133150
def close(self) -> None:
134151
self._http.close()
135152

0 commit comments

Comments
 (0)