feat(api): update via SDK Studio

This commit is contained in:
stainless-app[bot] 2025-06-27 14:47:07 +00:00
parent ddb79fc19d
commit a6cf7c5b2a
109 changed files with 159 additions and 153 deletions

View file

@ -7,9 +7,9 @@ from typing import Any, cast
import pytest
from opencode import Opencode, AsyncOpencode
from opencode_ai import Opencode, AsyncOpencode
from tests.utils import assert_matches_type
from opencode.types import App, AppInitResponse
from opencode_ai.types import App, AppInitResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")

View file

@ -7,9 +7,9 @@ from typing import Any, cast
import pytest
from opencode import Opencode, AsyncOpencode
from opencode_ai import Opencode, AsyncOpencode
from tests.utils import assert_matches_type
from opencode.types import Config, ConfigProvidersResponse
from opencode_ai.types import Config, ConfigProvidersResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")

View file

@ -7,9 +7,9 @@ from typing import Any, cast
import pytest
from opencode import Opencode, AsyncOpencode
from opencode_ai import Opencode, AsyncOpencode
from tests.utils import assert_matches_type
from opencode.types import EventListResponse
from opencode_ai.types import EventListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")

View file

@ -7,9 +7,9 @@ from typing import Any, cast
import pytest
from opencode import Opencode, AsyncOpencode
from opencode_ai import Opencode, AsyncOpencode
from tests.utils import assert_matches_type
from opencode.types import FileSearchResponse
from opencode_ai.types import FileSearchResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")

View file

@ -7,9 +7,9 @@ from typing import Any, cast
import pytest
from opencode import Opencode, AsyncOpencode
from opencode_ai import Opencode, AsyncOpencode
from tests.utils import assert_matches_type
from opencode.types import (
from opencode_ai.types import (
Message,
Session,
SessionInitResponse,

View file

@ -10,15 +10,15 @@ import httpx
import pytest
from pytest_asyncio import is_async_test
from opencode import Opencode, AsyncOpencode, DefaultAioHttpClient
from opencode._utils import is_dict
from opencode_ai import Opencode, AsyncOpencode, DefaultAioHttpClient
from opencode_ai._utils import is_dict
if TYPE_CHECKING:
from _pytest.fixtures import FixtureRequest # pyright: ignore[reportPrivateImportUsage]
pytest.register_assert_rewrite("tests.utils")
logging.getLogger("opencode").setLevel(logging.DEBUG)
logging.getLogger("opencode_ai").setLevel(logging.DEBUG)
# automatically add `pytest.mark.asyncio()` to all of our async tests

View file

@ -21,11 +21,11 @@ import pytest
from respx import MockRouter
from pydantic import ValidationError
from opencode import Opencode, AsyncOpencode, APIResponseValidationError
from opencode._types import Omit
from opencode._models import BaseModel, FinalRequestOptions
from opencode._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
from opencode._base_client import (
from opencode_ai import Opencode, AsyncOpencode, APIResponseValidationError
from opencode_ai._types import Omit
from opencode_ai._models import BaseModel, FinalRequestOptions
from opencode_ai._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
from opencode_ai._base_client import (
DEFAULT_TIMEOUT,
HTTPX_DEFAULT_TIMEOUT,
BaseClient,
@ -223,10 +223,10 @@ class TestOpencode:
# to_raw_response_wrapper leaks through the @functools.wraps() decorator.
#
# removing the decorator fixes the leak for reasons we don't understand.
"opencode/_legacy_response.py",
"opencode/_response.py",
"opencode_ai/_legacy_response.py",
"opencode_ai/_response.py",
# pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason.
"opencode/_compat.py",
"opencode_ai/_compat.py",
# Standard library leaks we don't care about.
"/logging/__init__.py",
]
@ -671,7 +671,7 @@ class TestOpencode:
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Opencode) -> None:
respx_mock.get("/event").mock(side_effect=httpx.TimeoutException("Test timeout error"))
@ -681,7 +681,7 @@ class TestOpencode:
assert _get_open_connections(self.client) == 0
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Opencode) -> None:
respx_mock.get("/event").mock(return_value=httpx.Response(500))
@ -691,7 +691,7 @@ class TestOpencode:
assert _get_open_connections(self.client) == 0
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
def test_retries_taken(
@ -722,7 +722,7 @@ class TestOpencode:
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_omit_retry_count_header(
self, client: Opencode, failures_before_success: int, respx_mock: MockRouter
@ -745,7 +745,7 @@ class TestOpencode:
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_overwrite_retry_count_header(
self, client: Opencode, failures_before_success: int, respx_mock: MockRouter
@ -985,10 +985,10 @@ class TestAsyncOpencode:
# to_raw_response_wrapper leaks through the @functools.wraps() decorator.
#
# removing the decorator fixes the leak for reasons we don't understand.
"opencode/_legacy_response.py",
"opencode/_response.py",
"opencode_ai/_legacy_response.py",
"opencode_ai/_response.py",
# pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason.
"opencode/_compat.py",
"opencode_ai/_compat.py",
# Standard library leaks we don't care about.
"/logging/__init__.py",
]
@ -1439,7 +1439,7 @@ class TestAsyncOpencode:
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_timeout_errors_doesnt_leak(
self, respx_mock: MockRouter, async_client: AsyncOpencode
@ -1451,7 +1451,7 @@ class TestAsyncOpencode:
assert _get_open_connections(self.client) == 0
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_status_errors_doesnt_leak(
self, respx_mock: MockRouter, async_client: AsyncOpencode
@ -1463,7 +1463,7 @@ class TestAsyncOpencode:
assert _get_open_connections(self.client) == 0
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
@ -1495,7 +1495,7 @@ class TestAsyncOpencode:
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
async def test_omit_retry_count_header(
@ -1519,7 +1519,7 @@ class TestAsyncOpencode:
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
async def test_overwrite_retry_count_header(
@ -1553,8 +1553,8 @@ class TestAsyncOpencode:
import nest_asyncio
import threading
from opencode._utils import asyncify
from opencode._base_client import get_platform
from opencode_ai._utils import asyncify
from opencode_ai._base_client import get_platform
async def test_main() -> None:
result = await asyncify(get_platform)()

View file

@ -1,4 +1,4 @@
from opencode._utils import deepcopy_minimal
from opencode_ai._utils import deepcopy_minimal
def assert_different_identities(obj1: object, obj2: object) -> None:

View file

@ -4,8 +4,8 @@ from typing import Sequence
import pytest
from opencode._types import FileTypes
from opencode._utils import extract_files
from opencode_ai._types import FileTypes
from opencode_ai._utils import extract_files
def test_removes_files_from_input() -> None:

View file

@ -4,7 +4,7 @@ import anyio
import pytest
from dirty_equals import IsDict, IsList, IsBytes, IsTuple
from opencode._files import to_httpx_files, async_to_httpx_files
from opencode_ai._files import to_httpx_files, async_to_httpx_files
readme_path = Path(__file__).parent.parent.joinpath("README.md")

View file

@ -7,9 +7,9 @@ import pytest
import pydantic
from pydantic import Field
from opencode._utils import PropertyInfo
from opencode._compat import PYDANTIC_V2, parse_obj, model_dump, model_json
from opencode._models import BaseModel, construct_type
from opencode_ai._utils import PropertyInfo
from opencode_ai._compat import PYDANTIC_V2, parse_obj, model_dump, model_json
from opencode_ai._models import BaseModel, construct_type
class BasicModel(BaseModel):

View file

@ -4,7 +4,7 @@ from urllib.parse import unquote
import pytest
from opencode._qs import Querystring, stringify
from opencode_ai._qs import Querystring, stringify
def test_empty() -> None:

View file

@ -2,7 +2,7 @@ from __future__ import annotations
import pytest
from opencode._utils import required_args
from opencode_ai._utils import required_args
def test_too_many_positional_params() -> None:

View file

@ -6,8 +6,8 @@ import httpx
import pytest
import pydantic
from opencode import Opencode, BaseModel, AsyncOpencode
from opencode._response import (
from opencode_ai import Opencode, BaseModel, AsyncOpencode
from opencode_ai._response import (
APIResponse,
BaseAPIResponse,
AsyncAPIResponse,
@ -15,8 +15,8 @@ from opencode._response import (
AsyncBinaryAPIResponse,
extract_response_type,
)
from opencode._streaming import Stream
from opencode._base_client import FinalRequestOptions
from opencode_ai._streaming import Stream
from opencode_ai._base_client import FinalRequestOptions
class ConcreteBaseAPIResponse(APIResponse[bytes]): ...
@ -37,7 +37,7 @@ def test_extract_response_type_direct_classes() -> None:
def test_extract_response_type_direct_class_missing_type_arg() -> None:
with pytest.raises(
RuntimeError,
match="Expected type <class 'opencode._response.AsyncAPIResponse'> to have a type argument at index 0 but it did not",
match="Expected type <class 'opencode_ai._response.AsyncAPIResponse'> to have a type argument at index 0 but it did not",
):
extract_response_type(AsyncAPIResponse)
@ -68,7 +68,7 @@ def test_response_parse_mismatched_basemodel(client: Opencode) -> None:
with pytest.raises(
TypeError,
match="Pydantic models must subclass our base model type, e.g. `from opencode import BaseModel`",
match="Pydantic models must subclass our base model type, e.g. `from opencode_ai import BaseModel`",
):
response.parse(to=PydanticModel)
@ -86,7 +86,7 @@ async def test_async_response_parse_mismatched_basemodel(async_client: AsyncOpen
with pytest.raises(
TypeError,
match="Pydantic models must subclass our base model type, e.g. `from opencode import BaseModel`",
match="Pydantic models must subclass our base model type, e.g. `from opencode_ai import BaseModel`",
):
await response.parse(to=PydanticModel)

View file

@ -5,8 +5,8 @@ from typing import Iterator, AsyncIterator
import httpx
import pytest
from opencode import Opencode, AsyncOpencode
from opencode._streaming import Stream, AsyncStream, ServerSentEvent
from opencode_ai import Opencode, AsyncOpencode
from opencode_ai._streaming import Stream, AsyncStream, ServerSentEvent
@pytest.mark.asyncio

View file

@ -8,15 +8,15 @@ from typing_extensions import Required, Annotated, TypedDict
import pytest
from opencode._types import NOT_GIVEN, Base64FileInput
from opencode._utils import (
from opencode_ai._types import NOT_GIVEN, Base64FileInput
from opencode_ai._utils import (
PropertyInfo,
transform as _transform,
parse_datetime,
async_transform as _async_transform,
)
from opencode._compat import PYDANTIC_V2
from opencode._models import BaseModel
from opencode_ai._compat import PYDANTIC_V2
from opencode_ai._models import BaseModel
_T = TypeVar("_T")

View file

@ -2,7 +2,7 @@ import operator
from typing import Any
from typing_extensions import override
from opencode._utils import LazyProxy
from opencode_ai._utils import LazyProxy
class RecursiveLazyProxy(LazyProxy[Any]):

View file

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Generic, TypeVar, cast
from opencode._utils import extract_type_var_from_base
from opencode_ai._utils import extract_type_var_from_base
_T = TypeVar("_T")
_T2 = TypeVar("_T2")

View file

@ -8,8 +8,8 @@ from typing import Any, TypeVar, Iterator, cast
from datetime import date, datetime
from typing_extensions import Literal, get_args, get_origin, assert_type
from opencode._types import Omit, NoneType
from opencode._utils import (
from opencode_ai._types import Omit, NoneType
from opencode_ai._utils import (
is_dict,
is_list,
is_list_type,
@ -18,8 +18,8 @@ from opencode._utils import (
is_annotated_type,
is_type_alias_type,
)
from opencode._compat import PYDANTIC_V2, field_outer_type, get_model_fields
from opencode._models import BaseModel
from opencode_ai._compat import PYDANTIC_V2, field_outer_type, get_model_fields
from opencode_ai._models import BaseModel
BaseModelT = TypeVar("BaseModelT", bound=BaseModel)