Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ed8f79f
chore(test): do not count install time for mock server timeout
stainless-app[bot] Mar 6, 2026
d6bb8a8
chore(ci): skip uploading artifacts on stainless-internal branches
stainless-app[bot] Mar 7, 2026
74ac1d3
fix(pydantic): do not pass `by_alias` unless set
stainless-app[bot] Mar 17, 2026
f4373a8
fix(deps): bump minimum typing-extensions version
stainless-app[bot] Mar 17, 2026
536468f
chore(internal): tweak CI branches
stainless-app[bot] Mar 17, 2026
a5a6035
fix: sanitize endpoint path params
stainless-app[bot] Mar 20, 2026
5465c72
refactor(tests): switch from prism to steady
stainless-app[bot] Mar 20, 2026
814a31b
chore(tests): bump steady to v0.19.4
stainless-app[bot] Mar 21, 2026
f9bdfb4
chore(tests): bump steady to v0.19.5
stainless-app[bot] Mar 21, 2026
3009ce0
chore(internal): update gitignore
stainless-app[bot] Mar 24, 2026
9433bde
chore(tests): bump steady to v0.19.6
stainless-app[bot] Mar 24, 2026
ca93b8a
chore(ci): skip lint on metadata-only changes
stainless-app[bot] Mar 25, 2026
e2ddebd
chore(tests): bump steady to v0.19.7
stainless-app[bot] Mar 25, 2026
7afdedd
feat(internal): implement indices array format for query and form ser…
stainless-app[bot] Mar 27, 2026
4942675
chore(tests): bump steady to v0.20.1
stainless-app[bot] Apr 1, 2026
73a8f04
chore(tests): bump steady to v0.20.2
stainless-app[bot] Apr 1, 2026
bb86cc5
fix(client): preserve hardcoded query params when merging with user p…
stainless-app[bot] Apr 8, 2026
ca9efb2
fix: ensure file data are only sent as 1 parameter
stainless-app[bot] Apr 11, 2026
62638d4
perf(client): optimize file structure copying in multipart requests
stainless-app[bot] Apr 18, 2026
9c3fcb6
chore(tests): bump steady to v0.22.1
stainless-app[bot] Apr 18, 2026
6b2d3a7
release: 0.1.0-alpha.12
stainless-app[bot] Apr 18, 2026
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: 16 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6

Expand All @@ -36,7 +38,7 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
Expand All @@ -61,14 +63,18 @@ jobs:
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/zeroentropy-python'
if: |-
github.repository == 'stainless-sdks/zeroentropy-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/zeroentropy-python'
if: |-
github.repository == 'stainless-sdks/zeroentropy-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
_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.1.0-alpha.11"
".": "0.1.0-alpha.12"
}
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## 0.1.0-alpha.12 (2026-04-18)

Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/zeroentropy-ai/zeroentropy-python/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)

### Features

* **internal:** implement indices array format for query and form serialization ([7afdedd](https://github.com/zeroentropy-ai/zeroentropy-python/commit/7afdedd66e2dff463aef37287e84596240d9ec3a))


### Bug Fixes

* **client:** preserve hardcoded query params when merging with user params ([bb86cc5](https://github.com/zeroentropy-ai/zeroentropy-python/commit/bb86cc51decf47d411f9959dee26996fd2ec501b))
* **deps:** bump minimum typing-extensions version ([f4373a8](https://github.com/zeroentropy-ai/zeroentropy-python/commit/f4373a8d663cb8d2ca4212f77eade5269b518d1e))
* ensure file data are only sent as 1 parameter ([ca9efb2](https://github.com/zeroentropy-ai/zeroentropy-python/commit/ca9efb2c1f815a83b97e922cbf361f0fedd1cbc5))
* **pydantic:** do not pass `by_alias` unless set ([74ac1d3](https://github.com/zeroentropy-ai/zeroentropy-python/commit/74ac1d3f8dac62dc11de9550d88838d984301ca5))
* sanitize endpoint path params ([a5a6035](https://github.com/zeroentropy-ai/zeroentropy-python/commit/a5a60354eabb5dce3a6a8c519311cd8590995179))


### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([62638d4](https://github.com/zeroentropy-ai/zeroentropy-python/commit/62638d4e38f6dbe92abf136d98b105265eb3557f))


### Chores

* **ci:** skip lint on metadata-only changes ([ca93b8a](https://github.com/zeroentropy-ai/zeroentropy-python/commit/ca93b8ae56e0dddb8d49ecc21125c2a1751594c6))
* **ci:** skip uploading artifacts on stainless-internal branches ([d6bb8a8](https://github.com/zeroentropy-ai/zeroentropy-python/commit/d6bb8a8306064729e4739209011106a6cc5e224f))
* **internal:** tweak CI branches ([536468f](https://github.com/zeroentropy-ai/zeroentropy-python/commit/536468f4e298fb16e55818729b42fbc906a9d21f))
* **internal:** update gitignore ([3009ce0](https://github.com/zeroentropy-ai/zeroentropy-python/commit/3009ce0201a8f99cb608182617796dc71e17a910))
* **test:** do not count install time for mock server timeout ([ed8f79f](https://github.com/zeroentropy-ai/zeroentropy-python/commit/ed8f79f5b4c05cde5e12eb4c6a8137cc6b7dde74))
* **tests:** bump steady to v0.19.4 ([814a31b](https://github.com/zeroentropy-ai/zeroentropy-python/commit/814a31b0de576a870d04e41ef0b52da726741311))
* **tests:** bump steady to v0.19.5 ([f9bdfb4](https://github.com/zeroentropy-ai/zeroentropy-python/commit/f9bdfb48058be235113b6c19054a15e670d7c32b))
* **tests:** bump steady to v0.19.6 ([9433bde](https://github.com/zeroentropy-ai/zeroentropy-python/commit/9433bde7d0d7953ad3f9a7327bf1468f30f6d600))
* **tests:** bump steady to v0.19.7 ([e2ddebd](https://github.com/zeroentropy-ai/zeroentropy-python/commit/e2ddebd1af39af87aea48cc211b2b3520002f02c))
* **tests:** bump steady to v0.20.1 ([4942675](https://github.com/zeroentropy-ai/zeroentropy-python/commit/494267565119547a125bc548f258bda341c1925c))
* **tests:** bump steady to v0.20.2 ([73a8f04](https://github.com/zeroentropy-ai/zeroentropy-python/commit/73a8f04822fb42ddcbc63946b99801ca12c8e87e))
* **tests:** bump steady to v0.22.1 ([9c3fcb6](https://github.com/zeroentropy-ai/zeroentropy-python/commit/9c3fcb69b97fdb396880759e5bea46f54e0dde99))


### Refactors

* **tests:** switch from prism to steady ([5465c72](https://github.com/zeroentropy-ai/zeroentropy-python/commit/5465c7207251fa90b2281a7429c2f0f078632b2e))

## 0.1.0-alpha.11 (2026-03-03)

Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/zeroentropy-ai/zeroentropy-python/compare/v0.1.0-alpha.10...v0.1.0-alpha.11)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ pip install ./path-to-wheel-file.whl

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.

```sh
$ ./scripts/mock
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "zeroentropy"
version = "0.1.0-alpha.11"
version = "0.1.0-alpha.12"
description = "The official Python library for the ZeroEntropy API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -11,7 +11,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"typing-extensions>=4.14, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down
31 changes: 21 additions & 10 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,34 @@ fi

echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stdy/cli@0.22.1 -- steady --version

# Wait for server to come online
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=0
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
if ! kill -0 $! 2>/dev/null; then
echo
cat .stdy.log
exit 1
fi
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Steady server to start"
cat .stdy.log
exit 1
fi
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
fi
16 changes: 8 additions & 8 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
function steady_is_running() {
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
}

kill_server_on_port() {
Expand All @@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
if ! is_overriding_api_base_url && ! steady_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

Expand All @@ -36,19 +36,19 @@ fi
if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
elif ! steady_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
echo
fi

Expand Down
4 changes: 4 additions & 0 deletions src/zeroentropy/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ def _build_request(
files = cast(HttpxRequestFiles, ForceMultipartDict())

prepared_url = self._prepare_url(options.url)
# preserve hard-coded query params from the url
if params and prepared_url.query:
params = {**dict(prepared_url.params.items()), **params}
prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0])
if "_" in prepared_url.host:
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
Expand Down
11 changes: 9 additions & 2 deletions src/zeroentropy/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
from datetime import date, datetime
from typing_extensions import Self, Literal
from typing_extensions import Self, Literal, TypedDict

import pydantic
from pydantic.fields import FieldInfo
Expand Down Expand Up @@ -131,6 +131,10 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
return model.model_dump_json(indent=indent)


class _ModelDumpKwargs(TypedDict, total=False):
by_alias: bool


def model_dump(
model: pydantic.BaseModel,
*,
Expand All @@ -142,14 +146,17 @@ def model_dump(
by_alias: bool | None = None,
) -> dict[str, Any]:
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
kwargs: _ModelDumpKwargs = {}
if by_alias is not None:
kwargs["by_alias"] = by_alias
return model.model_dump(
mode=mode,
exclude=exclude,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
# warnings are not supported in Pydantic v1
warnings=True if PYDANTIC_V1 else warnings,
by_alias=by_alias,
**kwargs,
)
return cast(
"dict[str, Any]",
Expand Down
56 changes: 53 additions & 3 deletions src/zeroentropy/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io
import os
import pathlib
from typing import overload
from typing_extensions import TypeGuard
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard

import anyio

Expand All @@ -17,7 +17,9 @@
HttpxFileContent,
HttpxRequestFiles,
)
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t

_T = TypeVar("_T")


def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
Expand Down Expand Up @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
return await anyio.Path(file).read_bytes()

return file


def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
"""Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
{
"foo": {
"bar": {"baz": {}},
"files": {"file": <content>}
}
}
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
"""
return _deepcopy_with_paths(item, paths, 0)


def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
if not paths:
return item
if is_mapping(item):
key_to_paths: dict[str, list[Sequence[str]]] = {}
for path in paths:
if index < len(path):
key_to_paths.setdefault(path[index], []).append(path)

# if no path continues through this mapping, it won't be mutated and copying it is redundant
if not key_to_paths:
return item

result = dict(item)
for key, subpaths in key_to_paths.items():
if key in result:
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
return cast(_T, result)
if is_list(item):
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]

# if no path expects a list here, nothing will be mutated inside it - return by reference
if not array_paths:
return cast(_T, item)
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
return item
5 changes: 4 additions & 1 deletion src/zeroentropy/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def _stringify_item(
items.extend(self._stringify_item(key, item, opts))
return items
elif array_format == "indices":
raise NotImplementedError("The array indices format is not supported yet")
items = []
for i, item in enumerate(value):
items.extend(self._stringify_item(f"{key}[{i}]", item, opts))
return items
elif array_format == "brackets":
items = []
key = key + "[]"
Expand Down
2 changes: 1 addition & 1 deletion src/zeroentropy/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ._path import path_template as path_template
from ._sync import asyncify as asyncify
from ._proxy import LazyProxy as LazyProxy
from ._utils import (
Expand All @@ -23,7 +24,6 @@
coerce_integer as coerce_integer,
file_from_path as file_from_path,
strip_not_given as strip_not_given,
deepcopy_minimal as deepcopy_minimal,
get_async_library as get_async_library,
maybe_coerce_float as maybe_coerce_float,
get_required_header as get_required_header,
Expand Down
Loading