Skip to content

Commit 0b12963

Browse files
Merge pull request #348 from OneBusAway/release-please--branches--main--changes--next
release: 1.24.2
2 parents 90d7e14 + f5a3a01 commit 0b12963

14 files changed

Lines changed: 241 additions & 87 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-
".": "1.24.1"
2+
".": "1.24.2"
33
}

CHANGELOG.md

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

3+
## 1.24.2 (2026-04-18)
4+
5+
Full Changelog: [v1.24.1...v1.24.2](https://github.com/OneBusAway/python-sdk/compare/v1.24.1...v1.24.2)
6+
7+
### Bug Fixes
8+
9+
* **client:** preserve hardcoded query params when merging with user params ([fa95230](https://github.com/OneBusAway/python-sdk/commit/fa95230da42fb276e074db0d8f882d59172f867c))
10+
* ensure file data are only sent as 1 parameter ([abc0ea7](https://github.com/OneBusAway/python-sdk/commit/abc0ea7e46034c4d823f523cca5f2158b51a4133))
11+
12+
13+
### Performance Improvements
14+
15+
* **client:** optimize file structure copying in multipart requests ([8bc5ca0](https://github.com/OneBusAway/python-sdk/commit/8bc5ca020f09905a0d48ab3eaeded6f3ace8773d))
16+
17+
18+
### Chores
19+
20+
* **tests:** bump steady to v0.22.1 ([1bafb2f](https://github.com/OneBusAway/python-sdk/commit/1bafb2fd927eadf326b665dd8b50da58ecaf3048))
21+
322
## 1.24.1 (2026-04-01)
423

524
Full Changelog: [v1.24.0...v1.24.1](https://github.com/OneBusAway/python-sdk/compare/v1.24.0...v1.24.1)

pyproject.toml

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

scripts/mock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}"
2222
# Run steady mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
2424
# Pre-install the package so the download doesn't eat into the startup timeout
25-
npm exec --package=@stdy/cli@0.20.2 -- steady --version
25+
npm exec --package=@stdy/cli@0.22.1 -- steady --version
2626

27-
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
27+
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
2828

2929
# Wait for server to come online via health endpoint (max 30s)
3030
echo -n "Waiting for server"
@@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then
4848

4949
echo
5050
else
51-
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
51+
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
5252
fi

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ elif ! steady_is_running ; then
4343
echo -e "To run the server, pass in the path or url of your OpenAPI"
4444
echo -e "spec to the steady command:"
4545
echo
46-
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
46+
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=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
4747
echo
4848

4949
exit 1

src/onebusaway/_base_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ def _build_request(
540540
files = cast(HttpxRequestFiles, ForceMultipartDict())
541541

542542
prepared_url = self._prepare_url(options.url)
543+
# preserve hard-coded query params from the url
544+
if params and prepared_url.query:
545+
params = {**dict(prepared_url.params.items()), **params}
546+
prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0])
543547
if "_" in prepared_url.host:
544548
# work around https://github.com/encode/httpx/discussions/2880
545549
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}

src/onebusaway/_files.py

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import io
44
import os
55
import pathlib
6-
from typing import overload
7-
from typing_extensions import TypeGuard
6+
from typing import Sequence, cast, overload
7+
from typing_extensions import TypeVar, TypeGuard
88

99
import anyio
1010

@@ -17,7 +17,9 @@
1717
HttpxFileContent,
1818
HttpxRequestFiles,
1919
)
20-
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
20+
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t
21+
22+
_T = TypeVar("_T")
2123

2224

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

123125
return file
126+
127+
128+
def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
129+
"""Copy only the containers along the given paths.
130+
131+
Used to guard against mutation by extract_files without copying the entire structure.
132+
Only dicts and lists that lie on a path are copied; everything else
133+
is returned by reference.
134+
135+
For example, given paths=[["foo", "files", "file"]] and the structure:
136+
{
137+
"foo": {
138+
"bar": {"baz": {}},
139+
"files": {"file": <content>}
140+
}
141+
}
142+
The root dict, "foo", and "files" are copied (they lie on the path).
143+
"bar" and "baz" are returned by reference (off the path).
144+
"""
145+
return _deepcopy_with_paths(item, paths, 0)
146+
147+
148+
def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
149+
if not paths:
150+
return item
151+
if is_mapping(item):
152+
key_to_paths: dict[str, list[Sequence[str]]] = {}
153+
for path in paths:
154+
if index < len(path):
155+
key_to_paths.setdefault(path[index], []).append(path)
156+
157+
# if no path continues through this mapping, it won't be mutated and copying it is redundant
158+
if not key_to_paths:
159+
return item
160+
161+
result = dict(item)
162+
for key, subpaths in key_to_paths.items():
163+
if key in result:
164+
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
165+
return cast(_T, result)
166+
if is_list(item):
167+
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]
168+
169+
# if no path expects a list here, nothing will be mutated inside it - return by reference
170+
if not array_paths:
171+
return cast(_T, item)
172+
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
173+
return item

src/onebusaway/_utils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
coerce_integer as coerce_integer,
2525
file_from_path as file_from_path,
2626
strip_not_given as strip_not_given,
27-
deepcopy_minimal as deepcopy_minimal,
2827
get_async_library as get_async_library,
2928
maybe_coerce_float as maybe_coerce_float,
3029
get_required_header as get_required_header,

src/onebusaway/_utils/_utils.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def _extract_items(
8686
index += 1
8787
if is_dict(obj):
8888
try:
89-
# We are at the last entry in the path so we must remove the field
90-
if (len(path)) == index:
89+
# Remove the field if there are no more dict keys in the path,
90+
# only "<array>" traversal markers or end.
91+
if all(p == "<array>" for p in path[index:]):
9192
item = obj.pop(key)
9293
else:
9394
item = obj[key]
@@ -176,21 +177,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
176177
return isinstance(obj, Iterable)
177178

178179

179-
def deepcopy_minimal(item: _T) -> _T:
180-
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:
181-
182-
- mappings, e.g. `dict`
183-
- list
184-
185-
This is done for performance reasons.
186-
"""
187-
if is_mapping(item):
188-
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
189-
if is_list(item):
190-
return cast(_T, [deepcopy_minimal(entry) for entry in item])
191-
return item
192-
193-
194180
# copied from https://github.com/Rapptz/RoboDanny
195181
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
196182
size = len(seq)

src/onebusaway/_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__ = "onebusaway"
4-
__version__ = "1.24.1" # x-release-please-version
4+
__version__ = "1.24.2" # x-release-please-version

0 commit comments

Comments
 (0)