Skip to content

Commit c4b5e4b

Browse files
authored
Merge pull request #15 from context-dot-dev/release-please--branches--main--changes--next
release: 0.13.0
2 parents 6c60704 + 710ef71 commit c4b5e4b

17 files changed

Lines changed: 197 additions & 64 deletions

‎.release-please-manifest.json‎

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

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-a831ece9950c336fba69327e01aed391a08418e1898f4aff27a800471f139cc7.yml
3-
openapi_spec_hash: 459258410b739536cdc75b91e8b4eac7
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-d5ca4cac056c38a1cb69c6d9033abe0d2b4d5858ee9a76e1172b23649ab1cca6.yml
3+
openapi_spec_hash: 8e1dd204746bcfaaf637d93b1d339eb2
44
config_hash: 70354330f92ce169beabc98696ebb9a3

‎CHANGELOG.md‎

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

3+
## 0.13.0 (2026-04-30)
4+
5+
Full Changelog: [v0.12.0...v0.13.0](https://github.com/context-dot-dev/context-python-sdk/compare/v0.12.0...v0.13.0)
6+
7+
### Features
8+
9+
* **api:** api update ([c24a182](https://github.com/context-dot-dev/context-python-sdk/commit/c24a18236e7f9a4c9d84d6ead4ec0fecbdcf77fc))
10+
* **api:** api update ([c9c388e](https://github.com/context-dot-dev/context-python-sdk/commit/c9c388ecb41827df93f98ac8aa3c8f5ce754a13e))
11+
* support setting headers via env ([90d2e4e](https://github.com/context-dot-dev/context-python-sdk/commit/90d2e4e449b1af9541881775c771969d37f3a6f1))
12+
13+
14+
### Bug Fixes
15+
16+
* use correct field name format for multipart file arrays ([95fd70e](https://github.com/context-dot-dev/context-python-sdk/commit/95fd70ecf76c50261f4224b688584ae7ff8b52af))
17+
318
## 0.12.0 (2026-04-25)
419

520
Full Changelog: [v0.11.0...v0.12.0](https://github.com/context-dot-dev/context-python-sdk/compare/v0.11.0...v0.12.0)

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "context.dev"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
description = "The official Python library for the context.dev API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

‎src/context/dev/_client.py‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
RequestOptions,
2020
not_given,
2121
)
22-
from ._utils import is_given, get_async_library
22+
from ._utils import (
23+
is_given,
24+
is_mapping_t,
25+
get_async_library,
26+
)
2327
from ._compat import cached_property
2428
from ._version import __version__
2529
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
@@ -94,6 +98,15 @@ def __init__(
9498
if base_url is None:
9599
base_url = f"https://api.context.dev/v1"
96100

101+
custom_headers_env = os.environ.get("CONTEXT_DEV_CUSTOM_HEADERS")
102+
if custom_headers_env is not None:
103+
parsed: dict[str, str] = {}
104+
for line in custom_headers_env.split("\n"):
105+
colon = line.find(":")
106+
if colon >= 0:
107+
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
108+
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
109+
97110
super().__init__(
98111
version=__version__,
99112
base_url=base_url,
@@ -292,6 +305,15 @@ def __init__(
292305
if base_url is None:
293306
base_url = f"https://api.context.dev/v1"
294307

308+
custom_headers_env = os.environ.get("CONTEXT_DEV_CUSTOM_HEADERS")
309+
if custom_headers_env is not None:
310+
parsed: dict[str, str] = {}
311+
for line in custom_headers_env.split("\n"):
312+
colon = line.find(":")
313+
if colon >= 0:
314+
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
315+
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}
316+
295317
super().__init__(
296318
version=__version__,
297319
base_url=base_url,

‎src/context/dev/_qs.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
from typing import Any, List, Tuple, Union, Mapping, TypeVar
44
from urllib.parse import parse_qs, urlencode
5-
from typing_extensions import Literal, get_args
5+
from typing_extensions import get_args
66

7-
from ._types import NotGiven, not_given
7+
from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
88
from ._utils import flatten
99

1010
_T = TypeVar("_T")
1111

12-
13-
ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
14-
NestedFormat = Literal["dots", "brackets"]
15-
1612
PrimitiveData = Union[str, int, float, bool, None]
1713
# this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
1814
# https://github.com/microsoft/pyright/issues/3555

‎src/context/dev/_types.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
ModelT = TypeVar("ModelT", bound=pydantic.BaseModel)
4848
_T = TypeVar("_T")
4949

50+
ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
51+
NestedFormat = Literal["dots", "brackets"]
52+
5053

5154
# Approximates httpx internal ProxiesTypes and RequestFiles types
5255
# while adding support for `PathLike` instances

‎src/context/dev/_utils/_utils.py‎

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
)
1818
from pathlib import Path
1919
from datetime import date, datetime
20-
from typing_extensions import TypeGuard
20+
from typing_extensions import TypeGuard, get_args
2121

2222
import sniffio
2323

24-
from .._types import Omit, NotGiven, FileTypes, HeadersLike
24+
from .._types import Omit, NotGiven, FileTypes, ArrayFormat, HeadersLike
2525

2626
_T = TypeVar("_T")
2727
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
@@ -40,25 +40,45 @@ def extract_files(
4040
query: Mapping[str, object],
4141
*,
4242
paths: Sequence[Sequence[str]],
43+
array_format: ArrayFormat = "brackets",
4344
) -> list[tuple[str, FileTypes]]:
4445
"""Recursively extract files from the given dictionary based on specified paths.
4546
4647
A path may look like this ['foo', 'files', '<array>', 'data'].
4748
49+
``array_format`` controls how ``<array>`` segments contribute to the emitted
50+
field name. Supported values: ``"brackets"`` (``foo[]``), ``"repeat"`` and
51+
``"comma"`` (``foo``), ``"indices"`` (``foo[0]``, ``foo[1]``).
52+
4853
Note: this mutates the given dictionary.
4954
"""
5055
files: list[tuple[str, FileTypes]] = []
5156
for path in paths:
52-
files.extend(_extract_items(query, path, index=0, flattened_key=None))
57+
files.extend(_extract_items(query, path, index=0, flattened_key=None, array_format=array_format))
5358
return files
5459

5560

61+
def _array_suffix(array_format: ArrayFormat, array_index: int) -> str:
62+
if array_format == "brackets":
63+
return "[]"
64+
if array_format == "indices":
65+
return f"[{array_index}]"
66+
if array_format == "repeat" or array_format == "comma":
67+
# Both repeat the bare field name for each file part; there is no
68+
# meaningful way to comma-join binary parts.
69+
return ""
70+
raise NotImplementedError(
71+
f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
72+
)
73+
74+
5675
def _extract_items(
5776
obj: object,
5877
path: Sequence[str],
5978
*,
6079
index: int,
6180
flattened_key: str | None,
81+
array_format: ArrayFormat,
6282
) -> list[tuple[str, FileTypes]]:
6383
try:
6484
key = path[index]
@@ -75,9 +95,11 @@ def _extract_items(
7595

7696
if is_list(obj):
7797
files: list[tuple[str, FileTypes]] = []
78-
for entry in obj:
79-
assert_is_file_content(entry, key=flattened_key + "[]" if flattened_key else "")
80-
files.append((flattened_key + "[]", cast(FileTypes, entry)))
98+
for array_index, entry in enumerate(obj):
99+
suffix = _array_suffix(array_format, array_index)
100+
emitted_key = (flattened_key + suffix) if flattened_key else suffix
101+
assert_is_file_content(entry, key=emitted_key)
102+
files.append((emitted_key, cast(FileTypes, entry)))
81103
return files
82104

83105
assert_is_file_content(obj, key=flattened_key)
@@ -106,6 +128,7 @@ def _extract_items(
106128
path,
107129
index=index,
108130
flattened_key=flattened_key,
131+
array_format=array_format,
109132
)
110133
elif is_list(obj):
111134
if key != "<array>":
@@ -117,9 +140,12 @@ def _extract_items(
117140
item,
118141
path,
119142
index=index,
120-
flattened_key=flattened_key + "[]" if flattened_key is not None else "[]",
143+
flattened_key=(
144+
(flattened_key if flattened_key is not None else "") + _array_suffix(array_format, array_index)
145+
),
146+
array_format=array_format,
121147
)
122-
for item in obj
148+
for array_index, item in enumerate(obj)
123149
]
124150
)
125151

‎src/context/dev/_version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "context.dev"
4-
__version__ = "0.12.0" # x-release-please-version
4+
__version__ = "0.13.0" # x-release-please-version

0 commit comments

Comments
 (0)