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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
run: ./scripts/lint

build:
if: github.repository == 'stainless-sdks/writer-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-24.04
runs-on: ${{ github.repository == 'stainless-sdks/writer-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -61,12 +61,14 @@ jobs:
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/writer-python'
id: github-oidc
uses: actions/github-script@v6
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/writer-python'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.3.1"
".": "2.3.2-rc1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 33
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-9e04c6a51c55704029c529f2917d0e2b976cb7b6595128697db031ad7bd61a63.yml
openapi_spec_hash: e8a95522dd13ffe4633cccc34bbd651d
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-3f87c8deb39e443022f2e04252994a6c9d25473872503edf9eec00d874576b2d.yml
openapi_spec_hash: 5de52bf1d78e00b13a04f6e9ce2f2fb5
config_hash: 7a38bab086b53b43d2a719cb4d883264
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 2.3.2-rc1 (2025-09-11)

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

### Features

* improve future compat with pydantic v3 ([74315c4](https://github.com/writer/writer-python/commit/74315c493b0f439614d492378ae34fc0728c8bb1))
* **types:** replace List[str] with SequenceNotStr in params ([2c1a7de](https://github.com/writer/writer-python/commit/2c1a7de9a61c13b20b7734ba4f87da6ca7771e30))


### Bug Fixes

* avoid newer type syntax ([4aec590](https://github.com/writer/writer-python/commit/4aec5902d7329039817f2049c299458fa8eb1381))
* **client:** custom patch to prepare pydantic v3 ([8a26e46](https://github.com/writer/writer-python/commit/8a26e46ec365ea9905be7531bd80ebd9c74b129d))


### Chores

* **client:** format ([fa024a5](https://github.com/writer/writer-python/commit/fa024a58b0bc88104744f17279f5ca3819f28284))
* **client:** update stop params in stream/parse to match chat ([8920408](https://github.com/writer/writer-python/commit/8920408285a5adfe7d0a416bc4539e42326b180e))
* **internal:** add Sequence related utils ([40901e2](https://github.com/writer/writer-python/commit/40901e2ad2c45f6d8258df2e0666cc88c6c1fa0f))
* **internal:** change ci workflow machines ([84dcbed](https://github.com/writer/writer-python/commit/84dcbedf80ab51ed3d4379839682b0c584041bb9))
* **internal:** move mypy configurations to `pyproject.toml` file ([2518950](https://github.com/writer/writer-python/commit/251895049da0d7302cb37c599b0ca23dd0b6d470))
* **internal:** update pyright exclude list ([815b794](https://github.com/writer/writer-python/commit/815b794df77ae9e20842db345988c93f1f077ee7))
* **tests:** simplify `get_platform` test ([f1ddbb2](https://github.com/writer/writer-python/commit/f1ddbb236dbc6c1780eb1120e2fba20c0e4c921a))
* update github action ([d81d1ec](https://github.com/writer/writer-python/commit/d81d1ec4fe56a7761fd5c3ad2afc65e8b12954fd))


### Documentation

* **api:** updates to API spec ([daf31d5](https://github.com/writer/writer-python/commit/daf31d587a7bc32c9debe961ac870d08fedef865))
* **api:** updates to API spec ([5f8a109](https://github.com/writer/writer-python/commit/5f8a109801baff44a41313e2a4774ecc2c7e70bd))

## 2.3.1 (2025-08-20)

Full Changelog: [v2.3.1-rc1...v2.3.1](https://github.com/writer/writer-python/compare/v2.3.1-rc1...v2.3.1)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To install the package from PyPI, use `pip`:

```sh
# install from PyPI
pip install writer-sdk
pip install --pre writer-sdk
```

## Prequisites
Expand Down Expand Up @@ -116,7 +116,7 @@ You can enable this by installing `aiohttp`:

```sh
# install from PyPI
pip install writer-sdk[aiohttp]
pip install --pre writer-sdk[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand Down
50 changes: 0 additions & 50 deletions mypy.ini

This file was deleted.

55 changes: 54 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "writer-sdk"
version = "2.3.1"
version = "2.3.2-rc1"
description = "The official Python library for the writer API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -151,6 +151,7 @@ exclude = [
"_dev",
".venv",
".nox",
".git",
]

reportImplicitOverride = true
Expand All @@ -159,6 +160,58 @@ reportOverlappingOverload = false
reportImportCycles = false
reportPrivateUsage = false

[tool.mypy]
pretty = true
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.
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/writerai/_files.py', '_dev/.*.py', 'tests/.*']

strict_equality = true
implicit_reexport = true
check_untyped_defs = true
no_implicit_optional = true

warn_return_any = true
warn_unreachable = true
warn_unused_configs = true

# Turn these options off as it could cause conflicts
# with the Pyright options.
warn_unused_ignores = false
warn_redundant_casts = false

disallow_any_generics = true
disallow_untyped_defs = true
disallow_untyped_calls = true
disallow_subclassing_any = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
cache_fine_grained = true

# By default, mypy reports an error if you assign a value to the result
# of a function call that doesn't return anything. We do this in our test
# cases:
# ```
# result = ...
# assert result is None
# ```
# Changing this codegen to make mypy happy would increase complexity
# and would not be worth it.
disable_error_code = "func-returns-value,overload-cannot-match"

# https://github.com/python/mypy/issues/12162
[[tool.mypy.overrides]]
module = "black.files.*"
ignore_errors = true
ignore_missing_imports = true


[tool.ruff]
line-length = 120
output-format = "grouped"
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ anyio==4.4.0
# via writer-sdk
argcomplete==3.1.2
# via nox
asttokens==3.0.0
# via inline-snapshot
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
asttokens==3.0.0
# via inline-snapshot
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -43,10 +43,10 @@ distro==1.8.0
exceptiongroup==1.2.2
# via anyio
# via pytest
executing==2.2.0
# via inline-snapshot
execnet==2.1.1
# via pytest-xdist
executing==2.2.0
# via inline-snapshot
filelock==3.12.4
# via virtualenv
frozenlist==1.6.2
Expand Down
4 changes: 2 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ idna==3.4
# via anyio
# via httpx
# via yarl
jiter==0.8.2
# via writer-sdk
multidict==6.4.4
# via aiohttp
# via yarl
propcache==0.3.1
# via aiohttp
# via yarl
jiter==0.8.2
# via writer-sdk
pydantic==2.10.3
# via writer-sdk
pydantic-core==2.27.1
Expand Down
6 changes: 3 additions & 3 deletions src/writerai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
ModelBuilderProtocol,
)
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
from ._compat import PYDANTIC_V2, model_copy, model_dump
from ._compat import PYDANTIC_V1, model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
APIResponse,
Expand Down Expand Up @@ -233,7 +233,7 @@ def _set_private_attributes(
model: Type[_T],
options: FinalRequestOptions,
) -> None:
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
self.__pydantic_private__ = {}

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

self._model = model
Expand Down
7 changes: 2 additions & 5 deletions src/writerai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ def _extract_sdk_env_headers() -> dict[str, str]:
continue

# Strip the prefix and convert
raw = key[len(_SDK_HEADER_PREFIX):]
raw = key[len(_SDK_HEADER_PREFIX) :]
parts = raw.split("_")
canonical = "-".join(
word.capitalize() if len(word) > 1 else word.upper()
for word in parts
)
canonical = "-".join(word.capitalize() if len(word) > 1 else word.upper() for word in parts)
headers[canonical] = value

return headers
Expand Down
Loading