diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72ad9619..8814d63b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,13 +36,13 @@ jobs: run: ./scripts/lint build: - if: github.repository == 'stainless-sdks/steel-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork timeout-minutes: 10 name: build permissions: contents: read id-token: write - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/steel-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -61,12 +61,14 @@ jobs: run: rye build - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/steel-python' id: github-oidc uses: actions/github-script@v6 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Upload tarball + if: github.repository == 'stainless-sdks/steel-python' env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6d78745c..05988747 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.9.0" + ".": "0.9.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 8a67e3da..274298a9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 33 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-b5496a8d20faef3918563bbf1563b9c1f0ab280fa0aa32baca55faa95c8d8266.yml -openapi_spec_hash: b776cb76def983d026964ea90cdb3e29 -config_hash: 3dda15a7a3da8ba8e97a8ec239cbcb80 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-d693d9e2a0618bc5b31d9ebd9d651a63481620201dfab9d60bbc9cb2e4447dc9.yml +openapi_spec_hash: 33fd12f9846b38655baee7149258df34 +config_hash: 0ac588be60ea913482f5488577c17b6e diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c689b0f..df1a8add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.9.1 (2025-09-02) + +Full Changelog: [v0.9.0...v0.9.1](https://github.com/steel-dev/steel-python/compare/v0.9.0...v0.9.1) + +### Bug Fixes + +* avoid newer type syntax ([5791302](https://github.com/steel-dev/steel-python/commit/57913023bca4a08a7ae066351a4e44be45212e67)) +* timeout param issues ([8bf1ece](https://github.com/steel-dev/steel-python/commit/8bf1eced7e0966656d67ea4aad207ab5ed8235d4)) + + +### Chores + +* **internal:** add Sequence related utils ([ec2a5db](https://github.com/steel-dev/steel-python/commit/ec2a5db2fa3ff0855cb8e532a09a4e0a52387191)) +* **internal:** change ci workflow machines ([d7ce4e6](https://github.com/steel-dev/steel-python/commit/d7ce4e63f398c444339528f62c7ea893fc35f4ff)) +* **internal:** update pyright exclude list ([d0b2591](https://github.com/steel-dev/steel-python/commit/d0b2591f9890bd2069e1fb8f997f8c9f34bb5f4c)) +* update github action ([a001e5c](https://github.com/steel-dev/steel-python/commit/a001e5ca1eaaf635369486a859e62350c922e372)) + ## 0.9.0 (2025-08-22) Full Changelog: [v0.8.0...v0.9.0](https://github.com/steel-dev/steel-python/compare/v0.8.0...v0.9.0) diff --git a/pyproject.toml b/pyproject.toml index a096beb7..2e53a763 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "steel-sdk" -version = "0.9.0" +version = "0.9.1" description = "The official Python library for the steel API" dynamic = ["readme"] license = "Apache-2.0" @@ -148,6 +148,7 @@ exclude = [ "_dev", ".venv", ".nox", + ".git", ] reportImplicitOverride = true diff --git a/src/steel/_models.py b/src/steel/_models.py index b8387ce9..92f7c10b 100644 --- a/src/steel/_models.py +++ b/src/steel/_models.py @@ -304,7 +304,7 @@ def model_dump( exclude_none=exclude_none, ) - return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped + return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped @override def model_dump_json( diff --git a/src/steel/_types.py b/src/steel/_types.py index 883736bb..7fff9b93 100644 --- a/src/steel/_types.py +++ b/src/steel/_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/steel/_utils/__init__.py b/src/steel/_utils/__init__.py index d4fda26f..ca547ce5 100644 --- a/src/steel/_utils/__init__.py +++ b/src/steel/_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/steel/_utils/_typing.py b/src/steel/_utils/_typing.py index 1bac9542..845cd6b2 100644 --- a/src/steel/_utils/_typing.py +++ b/src/steel/_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/steel/_version.py b/src/steel/_version.py index 35995d6e..8522c69c 100644 --- a/src/steel/_version.py +++ b/src/steel/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "steel" -__version__ = "0.9.0" # x-release-please-version +__version__ = "0.9.1" # x-release-please-version diff --git a/src/steel/resources/sessions/sessions.py b/src/steel/resources/sessions/sessions.py index afd74998..fc2d3d92 100644 --- a/src/steel/resources/sessions/sessions.py +++ b/src/steel/resources/sessions/sessions.py @@ -537,7 +537,7 @@ async def create( "session_id": session_id, "solve_captcha": solve_captcha, "stealth_config": stealth_config, - "api_timeout": api_timeout, + "api_timeout": api_timeout or timeout, "use_proxy": use_proxy, "user_agent": user_agent, }, diff --git a/tests/utils.py b/tests/utils.py index d722e672..13a0710a 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: