Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
28ed8a4
fix(ci): release-doctor — report correct token name
stainless-app[bot] Jun 27, 2025
7e24628
chore(ci): only run for pushes and fork pull requests
stainless-app[bot] Jun 28, 2025
3704839
fix(ci): correct conditional
stainless-app[bot] Jun 30, 2025
38e5950
chore(ci): change upload type
stainless-app[bot] Jul 2, 2025
e0549e1
chore(internal): codegen related update
stainless-app[bot] Jul 8, 2025
3c70731
chore(internal): bump pinned h11 dep
stainless-app[bot] Jul 9, 2025
9478695
chore(package): mark python 3.13 as supported
stainless-app[bot] Jul 9, 2025
2cb7a26
fix(parsing): correctly handle nested discriminated unions
stainless-app[bot] Jul 10, 2025
42a31e7
chore(readme): fix version rendering on pypi
stainless-app[bot] Jul 11, 2025
e287360
fix(client): don't send Content-Type header on GET requests
stainless-app[bot] Jul 12, 2025
1e03cb6
feat: clean up environment call outs
stainless-app[bot] Jul 15, 2025
575e1d2
fix(parsing): ignore empty metadata
stainless-app[bot] Jul 22, 2025
c8d80ce
fix(parsing): parse extra field types
stainless-app[bot] Jul 23, 2025
0fd6229
chore(project): add settings file for vscode
stainless-app[bot] Jul 25, 2025
937d2d0
feat(client): support file upload requests
stainless-app[bot] Jul 31, 2025
0261de0
chore(internal): fix ruff target version
stainless-app[bot] Aug 6, 2025
d0b1bdf
chore: update @stainless-api/prism-cli to v5.15.0
stainless-app[bot] Aug 9, 2025
e29358f
chore(internal): update comment in script
stainless-app[bot] Aug 9, 2025
c33b98e
chore: update github action
stainless-app[bot] Aug 22, 2025
92a80ff
chore(internal): change ci workflow machines
stainless-app[bot] Aug 26, 2025
7a92a5c
fix: avoid newer type syntax
stainless-app[bot] Aug 27, 2025
3a3dedf
chore(internal): update pyright exclude list
stainless-app[bot] Aug 27, 2025
909caf9
chore(internal): add Sequence related utils
stainless-app[bot] Aug 30, 2025
4f55c7a
feat(types): replace List[str] with SequenceNotStr in params
stainless-app[bot] Sep 3, 2025
f35932d
feat: improve future compat with pydantic v3
stainless-app[bot] Sep 4, 2025
aa43f3d
chore(internal): move mypy configurations to `pyproject.toml` file
stainless-app[bot] Sep 5, 2025
f208b93
chore(tests): simplify `get_platform` test
stainless-app[bot] Sep 6, 2025
58abe7b
chore(internal): update pydantic dependency
stainless-app[bot] Sep 17, 2025
113e64c
chore(types): change optional parameter type from NotGiven to Omit
stainless-app[bot] Sep 19, 2025
3d03150
chore: do not install brew dependencies in ./scripts/bootstrap by def…
stainless-app[bot] Sep 20, 2025
4f57acd
chore(internal): detect missing future annotations with ruff
stainless-app[bot] Oct 11, 2025
7f956ad
chore: bump `httpx-aiohttp` version to 0.1.9
stainless-app[bot] Oct 18, 2025
6c79510
fix(client): close streams without requiring full consumption
stainless-app[bot] Oct 30, 2025
cb9e87b
chore(internal/tests): avoid race condition with implicit client cleanup
stainless-app[bot] Oct 31, 2025
d6036ed
chore(internal): grammar fix (it's -> its)
stainless-app[bot] Nov 4, 2025
32d0cf0
chore(package): drop Python 3.8 support
stainless-app[bot] Nov 11, 2025
fa4a2a8
fix: compat with Python 3.14
stainless-app[bot] Nov 11, 2025
3d5ccd6
fix(compat): update signatures of `model_dump` and `model_dump_json` …
stainless-app[bot] Nov 12, 2025
f75581a
chore: add Python 3.14 classifier and testing
stainless-app[bot] Nov 22, 2025
46c993c
fix: ensure streams are always closed
stainless-app[bot] Nov 28, 2025
fba448a
chore(deps): mypy 1.18.1 has a regression, pin to 1.17
stainless-app[bot] Nov 28, 2025
acbe330
release: 0.4.0
stainless-app[bot] Nov 28, 2025
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
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/patronus-api-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand All @@ -34,24 +35,40 @@ jobs:
- name: Run lints
run: ./scripts/lint

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

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/patronus-api-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/patronus-api-python'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand All @@ -62,6 +79,7 @@ jobs:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/patronus-api-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.prism.log
.vscode
_dev

__pycache__
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 @@
{
".": "0.3.0"
".": "0.4.0"
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.importFormat": "relative",
}
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Changelog

## 0.4.0 (2025-11-28)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/patronus-ai/patronus-api-python/compare/v0.3.0...v0.4.0)

### Features

* clean up environment call outs ([1e03cb6](https://github.com/patronus-ai/patronus-api-python/commit/1e03cb6851414edf1ee79c1c2340d475bf9185bb))
* **client:** support file upload requests ([937d2d0](https://github.com/patronus-ai/patronus-api-python/commit/937d2d00d5067ff76175481020c04f43af04bc06))
* improve future compat with pydantic v3 ([f35932d](https://github.com/patronus-ai/patronus-api-python/commit/f35932d7c6e2358a7cf608ec7deebe8a15f9eff4))
* **types:** replace List[str] with SequenceNotStr in params ([4f55c7a](https://github.com/patronus-ai/patronus-api-python/commit/4f55c7a77110635b15fc4039e2703675350ba26a))


### Bug Fixes

* avoid newer type syntax ([7a92a5c](https://github.com/patronus-ai/patronus-api-python/commit/7a92a5cdb7ba7e2dc908c470ea0a0324f186856f))
* **ci:** correct conditional ([3704839](https://github.com/patronus-ai/patronus-api-python/commit/370483900a3d06b2649482a089f6622faf5ff9f0))
* **ci:** release-doctor — report correct token name ([28ed8a4](https://github.com/patronus-ai/patronus-api-python/commit/28ed8a45a95f1f2d45984a4069c7d331d1b35ade))
* **client:** close streams without requiring full consumption ([6c79510](https://github.com/patronus-ai/patronus-api-python/commit/6c7951055dee58e2b05739448fd7d40faaf79887))
* **client:** don't send Content-Type header on GET requests ([e287360](https://github.com/patronus-ai/patronus-api-python/commit/e2873601346907211bd14fe63c2fb4e1054dc70f))
* compat with Python 3.14 ([fa4a2a8](https://github.com/patronus-ai/patronus-api-python/commit/fa4a2a8966d7940edf14c2db1cb0e424cd5c5704))
* **compat:** update signatures of `model_dump` and `model_dump_json` for Pydantic v1 ([3d5ccd6](https://github.com/patronus-ai/patronus-api-python/commit/3d5ccd6c7112ac2556df9df5a280735aa9f7f08b))
* ensure streams are always closed ([46c993c](https://github.com/patronus-ai/patronus-api-python/commit/46c993c348936aacb14de054812cc65df18fa063))
* **parsing:** correctly handle nested discriminated unions ([2cb7a26](https://github.com/patronus-ai/patronus-api-python/commit/2cb7a2600e036fc8202f85c9aff32d22b894a159))
* **parsing:** ignore empty metadata ([575e1d2](https://github.com/patronus-ai/patronus-api-python/commit/575e1d233868ada3d9b7e183891cb99c31331752))
* **parsing:** parse extra field types ([c8d80ce](https://github.com/patronus-ai/patronus-api-python/commit/c8d80cefcddc30a9c7e840fc2ab910fd941e0262))


### Chores

* add Python 3.14 classifier and testing ([f75581a](https://github.com/patronus-ai/patronus-api-python/commit/f75581abb144c98bf52809f13eb0c5c7a2408035))
* bump `httpx-aiohttp` version to 0.1.9 ([7f956ad](https://github.com/patronus-ai/patronus-api-python/commit/7f956adab3453a2b367c477dfcc5d5a8baced88c))
* **ci:** change upload type ([38e5950](https://github.com/patronus-ai/patronus-api-python/commit/38e5950c93f10ded69c989b8da05b7b2af4a666a))
* **ci:** only run for pushes and fork pull requests ([7e24628](https://github.com/patronus-ai/patronus-api-python/commit/7e2462815f27c92e023e3a5586d5ed78b148ca71))
* **deps:** mypy 1.18.1 has a regression, pin to 1.17 ([fba448a](https://github.com/patronus-ai/patronus-api-python/commit/fba448a5c172247633574f74da4cc3df10773678))
* do not install brew dependencies in ./scripts/bootstrap by default ([3d03150](https://github.com/patronus-ai/patronus-api-python/commit/3d031505fe22280b6a76e96173c6f6a03d5dd5f6))
* **internal/tests:** avoid race condition with implicit client cleanup ([cb9e87b](https://github.com/patronus-ai/patronus-api-python/commit/cb9e87b51c2c0d05b7638d55df820b08041d4d4f))
* **internal:** add Sequence related utils ([909caf9](https://github.com/patronus-ai/patronus-api-python/commit/909caf92dbc2bbc15ee94a7439362ffb570c8fbc))
* **internal:** bump pinned h11 dep ([3c70731](https://github.com/patronus-ai/patronus-api-python/commit/3c70731c7238cd7b3b160df374b1e849ca474606))
* **internal:** change ci workflow machines ([92a80ff](https://github.com/patronus-ai/patronus-api-python/commit/92a80ff096993b69ac081f43c777e22ce6623d19))
* **internal:** codegen related update ([e0549e1](https://github.com/patronus-ai/patronus-api-python/commit/e0549e1c620bab90e35b09e3671900f85df6bab7))
* **internal:** detect missing future annotations with ruff ([4f57acd](https://github.com/patronus-ai/patronus-api-python/commit/4f57acd88a4a6843f22f9966e1e15d296333eca2))
* **internal:** fix ruff target version ([0261de0](https://github.com/patronus-ai/patronus-api-python/commit/0261de0b4ba183196d4145ce258b9a77a7aa5f05))
* **internal:** grammar fix (it's -> its) ([d6036ed](https://github.com/patronus-ai/patronus-api-python/commit/d6036ed0c745f26487c3907f57c70ba958b40e0f))
* **internal:** move mypy configurations to `pyproject.toml` file ([aa43f3d](https://github.com/patronus-ai/patronus-api-python/commit/aa43f3d59410e9f47e647c79a17e749a6c96ed32))
* **internal:** update comment in script ([e29358f](https://github.com/patronus-ai/patronus-api-python/commit/e29358fbf136c6debc563309afdaa284e5566564))
* **internal:** update pydantic dependency ([58abe7b](https://github.com/patronus-ai/patronus-api-python/commit/58abe7b07d8a0110e6604bb35869692da921311d))
* **internal:** update pyright exclude list ([3a3dedf](https://github.com/patronus-ai/patronus-api-python/commit/3a3dedf985bcc3a00fb17f35207a5588da4dbe1d))
* **package:** drop Python 3.8 support ([32d0cf0](https://github.com/patronus-ai/patronus-api-python/commit/32d0cf0ba300381f52dd026db9ef7cd0e2633159))
* **package:** mark python 3.13 as supported ([9478695](https://github.com/patronus-ai/patronus-api-python/commit/947869586f25644664fe57aa6aa1ac9675f40fe4))
* **project:** add settings file for vscode ([0fd6229](https://github.com/patronus-ai/patronus-api-python/commit/0fd6229e501682ac87884d097e66d315ed4a64c1))
* **readme:** fix version rendering on pypi ([42a31e7](https://github.com/patronus-ai/patronus-api-python/commit/42a31e7a8cc11d3a20ecd88bec2e15b65a8f8df2))
* **tests:** simplify `get_platform` test ([f208b93](https://github.com/patronus-ai/patronus-api-python/commit/f208b930e1fd30e1ee07913943af6c853d1b27ad))
* **types:** change optional parameter type from NotGiven to Omit ([113e64c](https://github.com/patronus-ai/patronus-api-python/commit/113e64cb1a2ae02f113f197eb963327f4000b3b1))
* update @stainless-api/prism-cli to v5.15.0 ([d0b1bdf](https://github.com/patronus-ai/patronus-api-python/commit/d0b1bdf9fad7e779d6cb3d792b041d9a7e07d999))
* update github action ([c33b98e](https://github.com/patronus-ai/patronus-api-python/commit/c33b98ed79c03efdde217dcf9933f0ee640fc48b))

## 0.3.0 (2025-06-24)

Full Changelog: [v0.2.0...v0.3.0](https://github.com/patronus-ai/patronus-api-python/compare/v0.2.0...v0.3.0)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Patronus API Python API library

[![PyPI version](<https://img.shields.io/pypi/v/patronus-api.svg?label=pypi%20(stable)>)](https://pypi.org/project/patronus-api/)
<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/patronus-api.svg?label=pypi%20(stable))](https://pypi.org/project/patronus-api/)

The Patronus API Python library provides convenient access to the Patronus API REST API from any Python 3.8+
The Patronus API Python library provides convenient access to the Patronus API REST API from any Python 3.9+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand Down Expand Up @@ -100,15 +101,14 @@ pip install patronus-api[aiohttp]
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from patronus_api import DefaultAioHttpClient
from patronus_api import AsyncPatronusAPI


async def main() -> None:
async with AsyncPatronusAPI(
api_key=os.environ.get("PATRONUS_API_KEY"), # This is the default and can be omitted
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
response = await client.evaluations.evaluate(
Expand Down Expand Up @@ -442,7 +442,7 @@ print(patronus_api.__version__)

## Requirements

Python 3.8 or higher.
Python 3.9 or higher.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errors=()

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

lenErrors=${#errors[@]}
Expand Down
50 changes: 0 additions & 50 deletions mypy.ini

This file was deleted.

73 changes: 65 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "patronus-api"
version = "0.3.0"
version = "0.4.0"
description = "The official Python library for the patronus-api API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -15,15 +15,16 @@ dependencies = [
"distro>=1.7.0, <2",
"sniffio",
]
requires-python = ">= 3.8"
requires-python = ">= 3.9"
classifiers = [
"Typing :: Typed",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand All @@ -38,14 +39,14 @@ Homepage = "https://github.com/patronus-ai/patronus-api-python"
Repository = "https://github.com/patronus-ai/patronus-api-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]

[tool.rye]
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright==1.1.400",
"mypy",
"mypy==1.17",
"respx",
"pytest",
"pytest-asyncio",
Expand All @@ -55,7 +56,6 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0",
"pytest-xdist>=3.6.1",
]

Expand Down Expand Up @@ -141,12 +141,13 @@ filterwarnings = [
# there are a couple of flags that are still disabled by
# default in strict mode as they are experimental and niche.
typeCheckingMode = "strict"
pythonVersion = "3.8"
pythonVersion = "3.9"

exclude = [
"_dev",
".venv",
".nox",
".git",
]

reportImplicitOverride = true
Expand All @@ -155,10 +156,62 @@ 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/patronus_api/_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"
target-version = "py37"
target-version = "py38"

[tool.ruff.format]
docstring-code-format = true
Expand All @@ -171,6 +224,8 @@ select = [
"B",
# remove unused imports
"F401",
# check for missing future annotations
"FA102",
# bare except statements
"E722",
# unused arguments
Expand All @@ -193,6 +248,8 @@ unfixable = [
"T203",
]

extend-safe-fixes = ["FA102"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"

Expand Down
Loading
Loading