From eba7907ee5740d1280a2e8644505539d7e0f2bd2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 07:58:38 +0000 Subject: [PATCH 1/3] chore(internal): remove trailing character (#20) --- tests/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client.py b/tests/test_client.py index fed8d19..4691c66 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1637,7 +1637,7 @@ def test_get_platform(self) -> None: import threading from hubmap_search_sdk._utils import asyncify - from hubmap_search_sdk._base_client import get_platform + from hubmap_search_sdk._base_client import get_platform async def test_main() -> None: result = await asyncify(get_platform)() From 4605f8b1836a291ab658811a196cb46a3df818b0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 02:25:42 +0000 Subject: [PATCH 2/3] chore(internal): slight transform perf improvement (#23) --- src/hubmap_search_sdk/_utils/_transform.py | 22 ++++++++++++++++++++++ tests/test_transform.py | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/hubmap_search_sdk/_utils/_transform.py b/src/hubmap_search_sdk/_utils/_transform.py index 7ac2e17..3ec6208 100644 --- a/src/hubmap_search_sdk/_utils/_transform.py +++ b/src/hubmap_search_sdk/_utils/_transform.py @@ -142,6 +142,10 @@ def _maybe_transform_key(key: str, type_: type) -> str: return key +def _no_transform_needed(annotation: type) -> bool: + return annotation == float or annotation == int + + def _transform_recursive( data: object, *, @@ -184,6 +188,15 @@ def _transform_recursive( return cast(object, data) inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): @@ -332,6 +345,15 @@ async def _async_transform_recursive( return cast(object, data) inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): diff --git a/tests/test_transform.py b/tests/test_transform.py index 79a3516..670a592 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -432,3 +432,15 @@ async def test_base64_file_input(use_async: bool) -> None: assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == { "foo": "SGVsbG8sIHdvcmxkIQ==" } # type: ignore[comparison-overlap] + + +@parametrize +@pytest.mark.asyncio +async def test_transform_skipping(use_async: bool) -> None: + # lists of ints are left as-is + data = [1, 2, 3] + assert await transform(data, List[int], use_async) is data + + # iterables of ints are converted to a list + data = iter([1, 2, 3]) + assert await transform(data, Iterable[int], use_async) == [1, 2, 3] From 424a1d6a13874b9dc66ce5211a2e91343ba2d333 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 02:26:02 +0000 Subject: [PATCH 3/3] release: 1.0.0-alpha.3 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ pyproject.toml | 2 +- src/hubmap_search_sdk/_version.py | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ac0783c..81b3aa9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.0.0-alpha.2" + ".": "1.0.0-alpha.3" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a644e6b..a511e02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.0.0-alpha.3 (2025-04-09) + +Full Changelog: [v1.0.0-alpha.2...v1.0.0-alpha.3](https://github.com/hubmapconsortium/search-python-sdk/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) + +### Chores + +* **internal:** remove trailing character ([#20](https://github.com/hubmapconsortium/search-python-sdk/issues/20)) ([eba7907](https://github.com/hubmapconsortium/search-python-sdk/commit/eba7907ee5740d1280a2e8644505539d7e0f2bd2)) +* **internal:** slight transform perf improvement ([#23](https://github.com/hubmapconsortium/search-python-sdk/issues/23)) ([4605f8b](https://github.com/hubmapconsortium/search-python-sdk/commit/4605f8b1836a291ab658811a196cb46a3df818b0)) + ## 1.0.0-alpha.2 (2025-04-03) Full Changelog: [v1.0.0-alpha.1...v1.0.0-alpha.2](https://github.com/hubmapconsortium/search-python-sdk/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) diff --git a/pyproject.toml b/pyproject.toml index ed470f1..9327891 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "hubmap_search_sdk" -version = "1.0.0-alpha.2" +version = "1.0.0-alpha.3" description = "The official Python library for the hubmap-search-sdk API" dynamic = ["readme"] license = "MIT" diff --git a/src/hubmap_search_sdk/_version.py b/src/hubmap_search_sdk/_version.py index 9e0a91c..0d32fcd 100644 --- a/src/hubmap_search_sdk/_version.py +++ b/src/hubmap_search_sdk/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "hubmap_search_sdk" -__version__ = "1.0.0-alpha.2" # x-release-please-version +__version__ = "1.0.0-alpha.3" # x-release-please-version