Skip to content

Commit 3898c9f

Browse files
release: 2.2.1 (#240)
1 parent f530906 commit 3898c9f

39 files changed

Lines changed: 655 additions & 148 deletions

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ on:
77
- 'integrated/**'
88
- 'stl-preview-head/**'
99
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
1014

1115
jobs:
1216
lint:
1317
timeout-minutes: 10
1418
name: lint
1519
runs-on: ${{ github.repository == 'stainless-sdks/writer-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
1621
steps:
1722
- uses: actions/checkout@v4
1823

@@ -30,10 +35,49 @@ jobs:
3035
- name: Run lints
3136
run: ./scripts/lint
3237

38+
build:
39+
if: github.repository == 'stainless-sdks/writer-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
40+
timeout-minutes: 10
41+
name: build
42+
permissions:
43+
contents: read
44+
id-token: write
45+
runs-on: depot-ubuntu-24.04
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Install Rye
50+
run: |
51+
curl -sSf https://rye.astral.sh/get | bash
52+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
53+
env:
54+
RYE_VERSION: '0.44.0'
55+
RYE_INSTALL_OPTION: '--yes'
56+
57+
- name: Install dependencies
58+
run: rye sync --all-features
59+
60+
- name: Run build
61+
run: rye build
62+
63+
- name: Get GitHub OIDC Token
64+
id: github-oidc
65+
uses: actions/github-script@v6
66+
with:
67+
script: core.setOutput('github_token', await core.getIDToken());
68+
69+
- name: Upload tarball
70+
env:
71+
URL: https://pkg.stainless.com/s
72+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
73+
SHA: ${{ github.sha }}
74+
run: ./scripts/utils/upload-artifact.sh
75+
3376
test:
3477
timeout-minutes: 10
3578
name: test
3679
runs-on: ${{ github.repository == 'stainless-sdks/writer-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
80+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
3781
steps:
3882
- uses: actions/checkout@v4
3983

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.2.0"
2+
".": "2.2.1"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 32
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-07dea48ea85e600712dcdfd99a688f6a9cb8dd1f56d0a06e0ab54fc8a98a89b1.yml
3-
openapi_spec_hash: 0d30ab04c227bf53f3109dc4d861e5dc
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-fab7a71148b6f413a4425ca9f2ce3d42557b65d35ab28c6f64daa7fce6d0ffe2.yml
3+
openapi_spec_hash: 0ead6944545bc40172176e15cc704633
44
config_hash: c0c9f57ab19252f82cf765939edc61de

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
# Changelog
22

3+
## 2.2.1 (2025-07-16)
4+
5+
Full Changelog: [v2.2.0...v2.2.1](https://github.com/writer/writer-python/compare/v2.2.0...v2.2.1)
6+
7+
### Features
8+
9+
* clean up environment call outs ([fc436af](https://github.com/writer/writer-python/commit/fc436af17d30723e147c0cc8198886adfa43d0a1))
10+
* **client:** add follow_redirects request option ([1bf8218](https://github.com/writer/writer-python/commit/1bf8218881286ddf4bf1c9c2c4c8e8b58837425b))
11+
* **client:** add support for aiohttp ([843d69d](https://github.com/writer/writer-python/commit/843d69decc9eb5c1cb793fc466c026917e8036ce))
12+
13+
14+
### Bug Fixes
15+
16+
* allow utf-8 encoded filename in headers ([27ebc83](https://github.com/writer/writer-python/commit/27ebc83f9eb76b7ab2208ed8ac991bd857773928))
17+
* **ci:** correct conditional ([7f49d8d](https://github.com/writer/writer-python/commit/7f49d8d55819747831db0b7baa015b274b18108d))
18+
* **ci:** release-doctor — report correct token name ([0d20a9e](https://github.com/writer/writer-python/commit/0d20a9e7d8be4f8fbc316480335afd314d112a8a))
19+
* **client:** correctly parse binary response | stream ([55872c2](https://github.com/writer/writer-python/commit/55872c2302ae5458f872ab34809c85781f0f6f17))
20+
* **client:** don't send Content-Type header on GET requests ([ffcc579](https://github.com/writer/writer-python/commit/ffcc5799423bca552deabaa0cf98dc2e67d11a39))
21+
* merged_headers -> default_headers to avoid conflicts ([6b7aeb4](https://github.com/writer/writer-python/commit/6b7aeb4335534bcfafc2f9849fa4162f44002075))
22+
* **package:** support direct resource imports ([2016cda](https://github.com/writer/writer-python/commit/2016cda2813d2b49abf8f6aa2dafbecdcaddfa36))
23+
* **parsing:** correctly handle nested discriminated unions ([a4774a8](https://github.com/writer/writer-python/commit/a4774a8592d82d03ff1d2947ee61a909ac40d534))
24+
* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([f5db115](https://github.com/writer/writer-python/commit/f5db1150f0c8b53e9c9b471c1b1f555cfa6be2df))
25+
26+
27+
### Chores
28+
29+
* **ci:** change upload type ([9ee05fb](https://github.com/writer/writer-python/commit/9ee05fb02fede8fcba4418c55361080106f5172e))
30+
* **ci:** enable for pull requests ([2dc262b](https://github.com/writer/writer-python/commit/2dc262bf297d3d0f42489cf2c3e2ea59cb1a17cc))
31+
* **ci:** fix installation instructions ([b421fd0](https://github.com/writer/writer-python/commit/b421fd089015ede20a5cfa8214c19dc16b66f27c))
32+
* **ci:** only run for pushes and fork pull requests ([ced5ec3](https://github.com/writer/writer-python/commit/ced5ec33765e4d8454c597a135d20be8b89e0c4e))
33+
* **ci:** upload sdks to package manager ([bfc448f](https://github.com/writer/writer-python/commit/bfc448fb9516e07a3a5fa903ef04b2e838865a0a))
34+
* **docs:** grammar improvements ([302e1a8](https://github.com/writer/writer-python/commit/302e1a8fb48a3f0fa83bef9fa1fb5ee2244893f1))
35+
* **docs:** remove reference to rye shell ([b6a9aff](https://github.com/writer/writer-python/commit/b6a9aff0e0da58c0f19b4634448be6b6d539593c))
36+
* **docs:** remove unnecessary param examples ([b78bf04](https://github.com/writer/writer-python/commit/b78bf04d813ce51075386f660a0cfa3647db77d3))
37+
* **internal:** avoid errors for isinstance checks on proxies ([6bec701](https://github.com/writer/writer-python/commit/6bec701344af3c9cd7853cc9dcacfbd959dbf485))
38+
* **internal:** avoid lint errors in pagination expressions ([abf0203](https://github.com/writer/writer-python/commit/abf02038a3857004cbb061cffaa9f0bf29f841b0))
39+
* **internal:** bump pinned h11 dep ([383abab](https://github.com/writer/writer-python/commit/383ababb87995f734a70b58178d407b00df130ea))
40+
* **internal:** codegen related update ([81c98bd](https://github.com/writer/writer-python/commit/81c98bd5948b7b5d0175134f43ced00a559d3f41))
41+
* **internal:** update conftest.py ([f6aa1eb](https://github.com/writer/writer-python/commit/f6aa1eb979f08b6ee1f9518f19b618e9346c04c6))
42+
* **package:** mark python 3.13 as supported ([fe9f5d9](https://github.com/writer/writer-python/commit/fe9f5d904f516d1eb37037acd07df4e43e86246a))
43+
* parse environment variables for default headers ([fd7c358](https://github.com/writer/writer-python/commit/fd7c358ae9671a20c338d6868b4420b8a982fe17))
44+
* **readme:** fix version rendering on pypi ([b93bb29](https://github.com/writer/writer-python/commit/b93bb292fe04ff647049ef0b1431181435463c92))
45+
* **readme:** update badges ([52ec704](https://github.com/writer/writer-python/commit/52ec7049643a69006ad01aa7d3c47533e017afd9))
46+
* **tests:** add tests for httpx client instantiation & proxies ([5e99c8f](https://github.com/writer/writer-python/commit/5e99c8fae8879b664c7982fc88a0f5dfd0f111d7))
47+
* **tests:** run tests in parallel ([6c8b5ad](https://github.com/writer/writer-python/commit/6c8b5ad718480211ef16b7a81064eadb988c69de))
48+
* **tests:** skip some failing tests on the latest python versions ([94bb5d6](https://github.com/writer/writer-python/commit/94bb5d63562691568da5e2a48e4890dbbbcda456))
49+
50+
51+
### Documentation
52+
53+
* **api:** updates to API spec ([4902642](https://github.com/writer/writer-python/commit/4902642b8d9cc80b3bae1d5a10d44a0959e2d0b0))
54+
* **api:** updates to API spec ([e704323](https://github.com/writer/writer-python/commit/e7043234b044b7fa0897c2f3d07685d429071c08))
55+
* **client:** fix httpx.Timeout documentation reference ([f0cc6ef](https://github.com/writer/writer-python/commit/f0cc6ef6ac440627a7ed903142b79d49c3d0a22e))
56+
357
## 2.2.0 (2025-04-30)
458

559
Full Changelog: [v2.2.0-rc1...v2.2.0](https://github.com/writer/writer-python/compare/v2.2.0-rc1...v2.2.0)

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ $ rye sync --all-features
1717
You can then run scripts using `rye run python script.py` or by activating the virtual environment:
1818

1919
```sh
20-
$ rye shell
21-
# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work
20+
# Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work
2221
$ source .venv/bin/activate
2322

2423
# now you can omit the `rye run` prefix

README.md

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Writer Python API library
22

3-
[![PyPI version](https://img.shields.io/pypi/v/writer-sdk.svg)](https://pypi.org/project/writer-sdk/)
3+
<!-- prettier-ignore -->
4+
[![PyPI version](https://img.shields.io/pypi/v/writer-sdk.svg?label=pypi%20(stable))](https://pypi.org/project/writer-sdk/)
45

56
The Writer Python library provides access to the Writer REST API from any Python 3.8+
67
application. It includes a set of tools and utilities that make it easy to integrate the capabilities
@@ -107,7 +108,46 @@ asyncio.run(main())
107108

108109
Functionality between the synchronous and asynchronous clients is otherwise identical.
109110

110-
## Streaming versus non-streaming responses
111+
### With aiohttp
112+
113+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
114+
115+
You can enable this by installing `aiohttp`:
116+
117+
```sh
118+
# install from PyPI
119+
pip install writer-sdk[aiohttp]
120+
```
121+
122+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
123+
124+
```python
125+
import asyncio
126+
from writerai import DefaultAioHttpClient
127+
from writerai import AsyncWriter
128+
129+
130+
async def main() -> None:
131+
async with AsyncWriter(
132+
api_key="My API Key",
133+
http_client=DefaultAioHttpClient(),
134+
) as client:
135+
chat_completion = await client.chat.chat(
136+
messages=[
137+
{
138+
"content": "Write a haiku about programming",
139+
"role": "user",
140+
}
141+
],
142+
model="palmyra-x5",
143+
)
144+
print(chat_completion.id)
145+
146+
147+
asyncio.run(main())
148+
```
149+
150+
## Streaming responses
111151

112152
The Writer Python library provides support for streaming responses using Server Side Events (SSE).
113153

@@ -255,10 +295,7 @@ client = Writer()
255295
chat_completion = client.chat.chat(
256296
messages=[{"role": "user"}],
257297
model="model",
258-
response_format={
259-
"type": "text",
260-
"json_schema": {},
261-
},
298+
response_format={"type": "text"},
262299
)
263300
print(chat_completion.response_format)
264301
```
@@ -365,8 +402,8 @@ client.with_options(max_retries=5).chat.chat(
365402

366403
### Timeouts
367404

368-
By default, requests time out after three minutes. You can configure this with a `timeout` option,
369-
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
405+
By default requests time out after three minutes. You can configure this with a `timeout` option,
406+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
370407

371408
```python
372409
import httpx

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ before making any information public.
1616
## Reporting Non-SDK Related Security Issues
1717

1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
19-
or products provided by Writer please follow the respective company's security reporting guidelines.
19+
or products provided by Writer, please follow the respective company's security reporting guidelines.
2020

2121
### Writer Terms and Policies
2222

23-
Please contact dev-feedback@writer.com for any questions or concerns regarding security of our services.
23+
Please contact dev-feedback@writer.com for any questions or concerns regarding the security of our services.
2424

2525
---
2626

bin/check-release-environment

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
errors=()
44

55
if [ -z "${PYPI_TOKEN}" ]; then
6-
errors+=("The WRITER_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
6+
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
77
fi
88

99
lenErrors=${#errors[@]}

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "writer-sdk"
3-
version = "2.2.0"
3+
version = "2.2.1"
44
description = "The official Python library for the writer API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -26,6 +26,7 @@ classifiers = [
2626
"Programming Language :: Python :: 3.10",
2727
"Programming Language :: Python :: 3.11",
2828
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
2930
"Operating System :: OS Independent",
3031
"Operating System :: POSIX",
3132
"Operating System :: MacOS",
@@ -39,6 +40,8 @@ classifiers = [
3940
Homepage = "https://github.com/writer/writer-python"
4041
Repository = "https://github.com/writer/writer-python"
4142

43+
[project.optional-dependencies]
44+
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]
4245

4346
[tool.rye]
4447
managed = true
@@ -56,7 +59,8 @@ dev-dependencies = [
5659
"importlib-metadata>=6.7.0",
5760
"rich>=13.7.1",
5861
"inline-snapshot >=0.7.0",
59-
"nest_asyncio==1.6.0"
62+
"nest_asyncio==1.6.0",
63+
"pytest-xdist>=3.6.1",
6064
]
6165

6266
[tool.rye.scripts]
@@ -128,7 +132,7 @@ replacement = '[\1](https://github.com/writer/writer-python/tree/main/\g<2>)'
128132

129133
[tool.pytest.ini_options]
130134
testpaths = ["tests"]
131-
addopts = "--tb=short"
135+
addopts = "--tb=short -n auto"
132136
xfail_strict = true
133137
asyncio_mode = "auto"
134138
asyncio_default_fixture_loop_scope = "session"

requirements-dev.lock

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
# universal: false
1111

1212
-e file:.
13+
aiohappyeyeballs==2.6.1
14+
# via aiohttp
15+
aiohttp==3.12.8
16+
# via httpx-aiohttp
17+
# via writer-sdk
18+
aiosignal==1.3.2
19+
# via aiohttp
1320
annotated-types==0.6.0
1421
# via pydantic
1522
anyio==4.4.0
1623
# via httpx
1724
# via writer-sdk
1825
argcomplete==3.1.2
1926
# via nox
27+
async-timeout==5.0.1
28+
# via aiohttp
29+
attrs==25.3.0
30+
# via aiohttp
2031
asttokens==3.0.0
2132
# via inline-snapshot
2233
certifi==2023.7.22
@@ -34,18 +45,27 @@ exceptiongroup==1.2.2
3445
# via pytest
3546
executing==2.2.0
3647
# via inline-snapshot
48+
execnet==2.1.1
49+
# via pytest-xdist
3750
filelock==3.12.4
3851
# via virtualenv
39-
h11==0.14.0
52+
frozenlist==1.6.2
53+
# via aiohttp
54+
# via aiosignal
55+
h11==0.16.0
4056
# via httpcore
41-
httpcore==1.0.2
57+
httpcore==1.0.9
4258
# via httpx
4359
httpx==0.28.1
60+
# via httpx-aiohttp
4461
# via respx
4562
# via writer-sdk
63+
httpx-aiohttp==0.1.8
64+
# via writer-sdk
4665
idna==3.4
4766
# via anyio
4867
# via httpx
68+
# via yarl
4969
importlib-metadata==7.0.0
5070
iniconfig==2.0.0
5171
# via pytest
@@ -56,6 +76,9 @@ markdown-it-py==3.0.0
5676
# via rich
5777
mdurl==0.1.2
5878
# via markdown-it-py
79+
multidict==6.4.4
80+
# via aiohttp
81+
# via yarl
5982
mypy==1.14.1
6083
mypy-extensions==1.0.0
6184
# via mypy
@@ -70,6 +93,9 @@ platformdirs==3.11.0
7093
# via virtualenv
7194
pluggy==1.5.0
7295
# via pytest
96+
propcache==0.3.1
97+
# via aiohttp
98+
# via yarl
7399
pydantic==2.10.3
74100
# via writer-sdk
75101
pydantic-core==2.27.1
@@ -79,7 +105,9 @@ pygments==2.18.0
79105
pyright==1.1.399
80106
pytest==8.3.3
81107
# via pytest-asyncio
108+
# via pytest-xdist
82109
pytest-asyncio==0.24.0
110+
pytest-xdist==3.7.0
83111
python-dateutil==2.8.2
84112
# via time-machine
85113
pytz==2023.3.post1
@@ -102,12 +130,15 @@ tomli==2.0.2
102130
# via pytest
103131
typing-extensions==4.12.2
104132
# via anyio
133+
# via multidict
105134
# via mypy
106135
# via pydantic
107136
# via pydantic-core
108137
# via pyright
109138
# via writer-sdk
110139
virtualenv==20.24.5
111140
# via nox
141+
yarl==1.20.0
142+
# via aiohttp
112143
zipp==3.17.0
113144
# via importlib-metadata

0 commit comments

Comments
 (0)