diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 575c3461..0bfbe6c9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0-alpha.85" + ".": "0.2.0-alpha.86" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b05a990e..324469d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.2.0-alpha.86 (2025-09-02) + +Full Changelog: [v0.2.0-alpha.85...v0.2.0-alpha.86](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.85...v0.2.0-alpha.86) + +### Features + +* add Python 3.13 support with conditional PyArrow dependencies ([fbe37d6](https://github.com/openlayer-ai/openlayer-python/commit/fbe37d6a6382fe05e4cfb6c01020ed3b7618efff)) + + +### Chores + +* **internal:** add Sequence related utils ([5a28f7f](https://github.com/openlayer-ai/openlayer-python/commit/5a28f7f9ea38da7aa922248a9b5f086607af542c)) + ## 0.2.0-alpha.85 (2025-08-29) Full Changelog: [v0.2.0-alpha.84...v0.2.0-alpha.85](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.84...v0.2.0-alpha.85) diff --git a/pyproject.toml b/pyproject.toml index 9725f021..9171503e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openlayer" -version = "0.2.0-alpha.85" +version = "0.2.0-alpha.86" description = "The official Python library for the openlayer API" dynamic = ["readme"] license = "Apache-2.0" @@ -15,7 +15,8 @@ dependencies = [ "distro>=1.7.0, <2", "sniffio", "pandas; python_version >= '3.7'", - "pyarrow==15.0.2", + "pyarrow>=15.0.2,<=17.0.0; python_version == '3.8'", + "pyarrow>=18.0.0; python_version >= '3.9'", "pyyaml>=6.0", "requests_toolbelt>=1.0.0", "tqdm", diff --git a/src/openlayer/_types.py b/src/openlayer/_types.py index 75357538..8d9dfe1f 100644 --- a/src/openlayer/_types.py +++ b/src/openlayer/_types.py @@ -13,10 +13,21 @@ Mapping, TypeVar, Callable, + Iterator, Optional, Sequence, ) -from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable +from typing_extensions import ( + Set, + Literal, + Protocol, + TypeAlias, + TypedDict, + SupportsIndex, + overload, + override, + runtime_checkable, +) import httpx import pydantic @@ -217,3 +228,26 @@ class _GenericAlias(Protocol): class HttpxSendArgs(TypedDict, total=False): auth: httpx.Auth follow_redirects: bool + + +_T_co = TypeVar("_T_co", covariant=True) + + +if TYPE_CHECKING: + # This works because str.__contains__ does not accept object (either in typeshed or at runtime) + # https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285 + class SequenceNotStr(Protocol[_T_co]): + @overload + def __getitem__(self, index: SupportsIndex, /) -> _T_co: ... + @overload + def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ... + def __contains__(self, value: object, /) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T_co]: ... + def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ... + def count(self, value: Any, /) -> int: ... + def __reversed__(self) -> Iterator[_T_co]: ... +else: + # just point this to a normal `Sequence` at runtime to avoid having to special case + # deserializing our custom sequence type + SequenceNotStr = Sequence diff --git a/src/openlayer/_utils/__init__.py b/src/openlayer/_utils/__init__.py index d4fda26f..ca547ce5 100644 --- a/src/openlayer/_utils/__init__.py +++ b/src/openlayer/_utils/__init__.py @@ -38,6 +38,7 @@ extract_type_arg as extract_type_arg, is_iterable_type as is_iterable_type, is_required_type as is_required_type, + is_sequence_type as is_sequence_type, is_annotated_type as is_annotated_type, is_type_alias_type as is_type_alias_type, strip_annotated_type as strip_annotated_type, diff --git a/src/openlayer/_utils/_typing.py b/src/openlayer/_utils/_typing.py index 1bac9542..845cd6b2 100644 --- a/src/openlayer/_utils/_typing.py +++ b/src/openlayer/_utils/_typing.py @@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool: return (get_origin(typ) or typ) == list +def is_sequence_type(typ: type) -> bool: + origin = get_origin(typ) or typ + return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence + + def is_iterable_type(typ: type) -> bool: """If the given type is `typing.Iterable[T]`""" origin = get_origin(typ) or typ diff --git a/src/openlayer/_version.py b/src/openlayer/_version.py index 9b747fa1..bd3d3e72 100644 --- a/src/openlayer/_version.py +++ b/src/openlayer/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "openlayer" -__version__ = "0.2.0-alpha.85" # x-release-please-version +__version__ = "0.2.0-alpha.86" # x-release-please-version diff --git a/tests/utils.py b/tests/utils.py index 638a4e6b..1f672faf 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,7 +4,7 @@ import inspect import traceback import contextlib -from typing import Any, TypeVar, Iterator, cast +from typing import Any, TypeVar, Iterator, Sequence, cast from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type @@ -15,6 +15,7 @@ is_list_type, is_union_type, extract_type_arg, + is_sequence_type, is_annotated_type, is_type_alias_type, ) @@ -71,6 +72,13 @@ def assert_matches_type( if is_list_type(type_): return _assert_list_type(type_, value) + if is_sequence_type(type_): + assert isinstance(value, Sequence) + inner_type = get_args(type_)[0] + for entry in value: # type: ignore + assert_type(inner_type, entry) # type: ignore + return + if origin == str: assert isinstance(value, str) elif origin == int: