diff --git a/.release-please-manifest.json b/.release-please-manifest.json index bf0d0361..f391d416 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.5.0" + ".": "3.6.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 795842f6..bc93eafc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 82 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-4bee800ad604492e6ee5776c10e1668037755aeaae6ff6faa2d09a0c3763eeee.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-8e9dc6bfba12f2eba83e978265436d2d6daabb89b04188ee749a32b3e2a6f55d.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 69f1c266..a14db4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## 3.6.0 (2024-12-10) + +Full Changelog: [v3.5.0...v3.6.0](https://github.com/DataMini/asktable-python/compare/v3.5.0...v3.6.0) + +### Features + +* **api:** api update ([#56](https://github.com/DataMini/asktable-python/issues/56)) ([85f14bf](https://github.com/DataMini/asktable-python/commit/85f14bf4c1a6ab1847ea70a1f92ab9fc6b84792d)) +* **api:** api update ([#58](https://github.com/DataMini/asktable-python/issues/58)) ([d8e87aa](https://github.com/DataMini/asktable-python/commit/d8e87aa6f7882c7c30c25876c9cd97b975108487)) +* **api:** api update ([#60](https://github.com/DataMini/asktable-python/issues/60)) ([d2fde2c](https://github.com/DataMini/asktable-python/commit/d2fde2c2c9dce66f76a81110ece132d64d7e91df)) +* **api:** api update ([#61](https://github.com/DataMini/asktable-python/issues/61)) ([b2a2931](https://github.com/DataMini/asktable-python/commit/b2a2931c8ff148f7c9289e5f3a26e212f0a00b6a)) +* **api:** api update ([#62](https://github.com/DataMini/asktable-python/issues/62)) ([9a0ade8](https://github.com/DataMini/asktable-python/commit/9a0ade84afdd1533abe882ddff731b7e62dfe949)) + + +### Bug Fixes + +* **client:** compat with new httpx 0.28.0 release ([#55](https://github.com/DataMini/asktable-python/issues/55)) ([9b90d53](https://github.com/DataMini/asktable-python/commit/9b90d53934ef35395dd9760e0440cf97e6e0c148)) + + +### Chores + +* **internal:** bump pydantic dependency ([#63](https://github.com/DataMini/asktable-python/issues/63)) ([73e26c6](https://github.com/DataMini/asktable-python/commit/73e26c6a80a0a77afaa0a7592f255a2505ac2dcf)) +* **internal:** bump pyright ([#57](https://github.com/DataMini/asktable-python/issues/57)) ([a4d4a4c](https://github.com/DataMini/asktable-python/commit/a4d4a4c6a4e9c0bc6f84eccd33ffba754f90a6e5)) +* **internal:** codegen related update ([#52](https://github.com/DataMini/asktable-python/issues/52)) ([5ca5165](https://github.com/DataMini/asktable-python/commit/5ca5165218fbe650f9ce1d4dc27cbc2b258c5b62)) +* **internal:** codegen related update ([#64](https://github.com/DataMini/asktable-python/issues/64)) ([aa903ed](https://github.com/DataMini/asktable-python/commit/aa903ede9be8e28ba1c2f05cda4455940627f630)) +* **internal:** exclude mypy from running on tests ([#54](https://github.com/DataMini/asktable-python/issues/54)) ([3e6ef7b](https://github.com/DataMini/asktable-python/commit/3e6ef7bdd00bd2af75f762c5002d754b314fdf99)) +* make the `Omit` type public ([#59](https://github.com/DataMini/asktable-python/issues/59)) ([ebaba2d](https://github.com/DataMini/asktable-python/commit/ebaba2d5e62fad4fa7091436b5713d1096620090)) + ## 3.5.0 (2024-11-25) Full Changelog: [v3.4.0...v3.5.0](https://github.com/DataMini/asktable-python/compare/v3.4.0...v3.5.0) diff --git a/README.md b/README.md index a54f961c..dff222b4 100644 --- a/README.md +++ b/README.md @@ -235,12 +235,14 @@ Note that requests that time out are [retried twice by default](#retries). We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module. -You can enable logging by setting the environment variable `ASKTABLE_LOG` to `debug`. +You can enable logging by setting the environment variable `ASKTABLE_LOG` to `info`. ```shell -$ export ASKTABLE_LOG=debug +$ export ASKTABLE_LOG=info ``` +Or to `debug` for more verbose logging. + ### How to tell whether `None` means `null` or missing In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`: @@ -331,18 +333,19 @@ can also get all the extra fields on the Pydantic model as a dict with You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including: -- Support for proxies -- Custom transports +- Support for [proxies](https://www.python-httpx.org/advanced/proxies/) +- Custom [transports](https://www.python-httpx.org/advanced/transports/) - Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality ```python +import httpx from asktable import Asktable, DefaultHttpxClient client = Asktable( # Or use the `ASKTABLE_BASE_URL` env var base_url="http://my.test.server.example.com:8083", http_client=DefaultHttpxClient( - proxies="http://my.test.proxy.example.com", + proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0"), ), ) diff --git a/mypy.ini b/mypy.ini index 92d44ac2..19fe81b2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,7 +5,10 @@ show_error_codes = True # Exclude _files.py because mypy isn't smart enough to apply # the correct type narrowing and as this is an internal module # it's fine to just use Pyright. -exclude = ^(src/asktable/_files\.py|_dev/.*\.py)$ +# +# We also exclude our `tests` as mypy doesn't always infer +# types correctly and Pyright will still catch any type errors. +exclude = ^(src/asktable/_files\.py|_dev/.*\.py|tests/.*)$ strict_equality = True implicit_reexport = True diff --git a/pyproject.toml b/pyproject.toml index de06d572..9ec953f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "asktable" -version = "3.5.0" +version = "3.6.0" description = "The official Python library for the asktable API" dynamic = ["readme"] license = "Apache-2.0" @@ -14,7 +14,6 @@ dependencies = [ "anyio>=3.5.0, <5", "distro>=1.7.0, <2", "sniffio", - "cached-property; python_version < '3.8'", ] requires-python = ">= 3.8" classifiers = [ diff --git a/requirements-dev.lock b/requirements-dev.lock index 17486d77..577cfe3d 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -62,13 +62,13 @@ platformdirs==3.11.0 # via virtualenv pluggy==1.5.0 # via pytest -pydantic==2.9.2 +pydantic==2.10.3 # via asktable -pydantic-core==2.23.4 +pydantic-core==2.27.1 # via pydantic pygments==2.18.0 # via rich -pyright==1.1.380 +pyright==1.1.389 pytest==8.3.3 # via pytest-asyncio pytest-asyncio==0.24.0 @@ -97,6 +97,7 @@ typing-extensions==4.12.2 # via mypy # via pydantic # via pydantic-core + # via pyright virtualenv==20.24.5 # via nox zipp==3.17.0 diff --git a/requirements.lock b/requirements.lock index d60ddeee..b09dda77 100644 --- a/requirements.lock +++ b/requirements.lock @@ -30,9 +30,9 @@ httpx==0.25.2 idna==3.4 # via anyio # via httpx -pydantic==2.9.2 +pydantic==2.10.3 # via asktable -pydantic-core==2.23.4 +pydantic-core==2.27.1 # via pydantic sniffio==1.3.0 # via anyio diff --git a/src/asktable/__init__.py b/src/asktable/__init__.py index 6d06a6b0..2bf9f563 100644 --- a/src/asktable/__init__.py +++ b/src/asktable/__init__.py @@ -1,7 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from . import types -from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes +from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes from ._utils import file_from_path from ._client import ( Client, @@ -46,6 +46,7 @@ "ProxiesTypes", "NotGiven", "NOT_GIVEN", + "Omit", "AsktableError", "APIError", "APIStatusError", diff --git a/src/asktable/_base_client.py b/src/asktable/_base_client.py index c2e8edda..16af16e1 100644 --- a/src/asktable/_base_client.py +++ b/src/asktable/_base_client.py @@ -792,6 +792,7 @@ def __init__( custom_query: Mapping[str, object] | None = None, _strict_response_validation: bool, ) -> None: + kwargs: dict[str, Any] = {} if limits is not None: warnings.warn( "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", @@ -804,6 +805,7 @@ def __init__( limits = DEFAULT_CONNECTION_LIMITS if transport is not None: + kwargs["transport"] = transport warnings.warn( "The `transport` argument is deprecated. The `http_client` argument should be passed instead", category=DeprecationWarning, @@ -813,6 +815,7 @@ def __init__( raise ValueError("The `http_client` argument is mutually exclusive with `transport`") if proxies is not None: + kwargs["proxies"] = proxies warnings.warn( "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", category=DeprecationWarning, @@ -856,10 +859,9 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, limits=limits, follow_redirects=True, + **kwargs, # type: ignore ) def is_closed(self) -> bool: @@ -1358,6 +1360,7 @@ def __init__( custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, ) -> None: + kwargs: dict[str, Any] = {} if limits is not None: warnings.warn( "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", @@ -1370,6 +1373,7 @@ def __init__( limits = DEFAULT_CONNECTION_LIMITS if transport is not None: + kwargs["transport"] = transport warnings.warn( "The `transport` argument is deprecated. The `http_client` argument should be passed instead", category=DeprecationWarning, @@ -1379,6 +1383,7 @@ def __init__( raise ValueError("The `http_client` argument is mutually exclusive with `transport`") if proxies is not None: + kwargs["proxies"] = proxies warnings.warn( "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", category=DeprecationWarning, @@ -1422,10 +1427,9 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, limits=limits, follow_redirects=True, + **kwargs, # type: ignore ) def is_closed(self) -> bool: diff --git a/src/asktable/_compat.py b/src/asktable/_compat.py index 4794129c..92d9ee61 100644 --- a/src/asktable/_compat.py +++ b/src/asktable/_compat.py @@ -145,7 +145,8 @@ def model_dump( exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, - warnings=warnings, + # warnings are not supported in Pydantic v1 + warnings=warnings if PYDANTIC_V2 else True, ) return cast( "dict[str, Any]", @@ -213,9 +214,6 @@ def __set_name__(self, owner: type[Any], name: str) -> None: ... # __set__ is not defined at runtime, but @cached_property is designed to be settable def __set__(self, instance: object, value: _T) -> None: ... else: - try: - from functools import cached_property as cached_property - except ImportError: - from cached_property import cached_property as cached_property + from functools import cached_property as cached_property typed_cached_property = cached_property diff --git a/src/asktable/_types.py b/src/asktable/_types.py index d241f718..6bc9be4a 100644 --- a/src/asktable/_types.py +++ b/src/asktable/_types.py @@ -192,10 +192,8 @@ def get(self, __key: str) -> str | None: ... StrBytesIntFloat = Union[str, bytes, int, float] # Note: copied from Pydantic -# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49 -IncEx: TypeAlias = Union[ - Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]] -] +# https://github.com/pydantic/pydantic/blob/6f31f8f68ef011f84357330186f603ff295312fd/pydantic/main.py#L79 +IncEx: TypeAlias = Union[Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]]] PostParser = Callable[[Any], Any] diff --git a/src/asktable/_version.py b/src/asktable/_version.py index 9f34309e..ded79dad 100644 --- a/src/asktable/_version.py +++ b/src/asktable/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "asktable" -__version__ = "3.5.0" # x-release-please-version +__version__ = "3.6.0" # x-release-please-version diff --git a/src/asktable/resources/datasources/datasources.py b/src/asktable/resources/datasources/datasources.py index 360dcdca..b8746aef 100644 --- a/src/asktable/resources/datasources/datasources.py +++ b/src/asktable/resources/datasources/datasources.py @@ -94,7 +94,7 @@ def with_streaming_response(self) -> DatasourcesResourceWithStreamingResponse: def create( self, *, - engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks"], + engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"], async_process_meta: bool | NotGiven = NOT_GIVEN, value_index: bool | NotGiven = NOT_GIVEN, access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, @@ -428,7 +428,7 @@ def with_streaming_response(self) -> AsyncDatasourcesResourceWithStreamingRespon async def create( self, *, - engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks"], + engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"], async_process_meta: bool | NotGiven = NOT_GIVEN, value_index: bool | NotGiven = NOT_GIVEN, access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, diff --git a/src/asktable/resources/securetunnels.py b/src/asktable/resources/securetunnels.py index ed5b8198..839ee70a 100644 --- a/src/asktable/resources/securetunnels.py +++ b/src/asktable/resources/securetunnels.py @@ -56,7 +56,7 @@ def with_streaming_response(self) -> SecuretunnelsResourceWithStreamingResponse: def create( self, *, - name: Optional[str] | NotGiven = NOT_GIVEN, + name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -124,8 +124,8 @@ def update( self, securetunnel_id: str, *, + name: str, client_info: Optional[object] | NotGiven = NOT_GIVEN, - name: Optional[str] | NotGiven = NOT_GIVEN, unique_key: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -138,10 +138,10 @@ def update( 更新某个 ATST Args: - client_info: 客户端信息 - name: SecureTunnel 名称,不超过 20 个字符 + client_info: 客户端信息 + unique_key: 唯一标识,用于更新客户端信息(容器 ID) extra_headers: Send extra headers @@ -158,8 +158,8 @@ def update( f"/securetunnels/{securetunnel_id}", body=maybe_transform( { - "client_info": client_info, "name": name, + "client_info": client_info, "unique_key": unique_key, }, securetunnel_update_params.SecuretunnelUpdateParams, @@ -325,7 +325,7 @@ def with_streaming_response(self) -> AsyncSecuretunnelsResourceWithStreamingResp async def create( self, *, - name: Optional[str] | NotGiven = NOT_GIVEN, + name: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -393,8 +393,8 @@ async def update( self, securetunnel_id: str, *, + name: str, client_info: Optional[object] | NotGiven = NOT_GIVEN, - name: Optional[str] | NotGiven = NOT_GIVEN, unique_key: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -407,10 +407,10 @@ async def update( 更新某个 ATST Args: - client_info: 客户端信息 - name: SecureTunnel 名称,不超过 20 个字符 + client_info: 客户端信息 + unique_key: 唯一标识,用于更新客户端信息(容器 ID) extra_headers: Send extra headers @@ -427,8 +427,8 @@ async def update( f"/securetunnels/{securetunnel_id}", body=await async_maybe_transform( { - "client_info": client_info, "name": name, + "client_info": client_info, "unique_key": unique_key, }, securetunnel_update_params.SecuretunnelUpdateParams, diff --git a/src/asktable/types/datasource.py b/src/asktable/types/datasource.py index f3647f0d..4efaf84b 100644 --- a/src/asktable/types/datasource.py +++ b/src/asktable/types/datasource.py @@ -16,6 +16,9 @@ class AccessConfig(BaseModel): db: Optional[str] = None """数据库引擎可以管理多个数据库,此参数用于指定数据库名称""" + db_version: Optional[str] = None + """数据库版本""" + host: Optional[str] = None """数据库地址""" @@ -48,7 +51,7 @@ class Datasource(BaseModel): created_at: datetime """创建时间""" - engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks"] + engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"] """数据源引擎""" meta_status: Literal["processing", "failed", "success", "unprocessed"] diff --git a/src/asktable/types/datasource_create_params.py b/src/asktable/types/datasource_create_params.py index cf563292..851416b7 100644 --- a/src/asktable/types/datasource_create_params.py +++ b/src/asktable/types/datasource_create_params.py @@ -9,7 +9,9 @@ class DatasourceCreateParams(TypedDict, total=False): - engine: Required[Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks"]] + engine: Required[ + Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"] + ] """数据源引擎""" async_process_meta: bool @@ -30,6 +32,9 @@ class AccessConfig(TypedDict, total=False): db: Optional[str] """数据库引擎可以管理多个数据库,此参数用于指定数据库名称""" + db_version: Optional[str] + """数据库版本""" + host: Optional[str] """数据库地址""" diff --git a/src/asktable/types/datasource_update_params.py b/src/asktable/types/datasource_update_params.py index 7ef08227..b814e4d8 100644 --- a/src/asktable/types/datasource_update_params.py +++ b/src/asktable/types/datasource_update_params.py @@ -44,6 +44,9 @@ class AccessConfig(TypedDict, total=False): db: Optional[str] """数据库引擎可以管理多个数据库,此参数用于指定数据库名称""" + db_version: Optional[str] + """数据库版本""" + host: Optional[str] """数据库地址""" diff --git a/src/asktable/types/index.py b/src/asktable/types/index.py index 53012b27..a558c037 100644 --- a/src/asktable/types/index.py +++ b/src/asktable/types/index.py @@ -45,5 +45,8 @@ class Index(BaseModel): min_length: Optional[int] = None """最小长度""" + status_msg: Optional[str] = None + """状态信息""" + value_count: Optional[int] = None """值总数""" diff --git a/src/asktable/types/meta.py b/src/asktable/types/meta.py index 6a42ac8a..1395bdf5 100644 --- a/src/asktable/types/meta.py +++ b/src/asktable/types/meta.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Dict, Optional +from datetime import datetime from .._models import BaseModel @@ -8,12 +9,18 @@ class SchemasTablesFields(BaseModel): + created_at: datetime + """created time""" + curr_desc_stat: str """current field description status""" full_name: str """field full name""" + modified_at: datetime + """modified time""" + name: str """field_name""" diff --git a/src/asktable/types/secure_tunnel.py b/src/asktable/types/secure_tunnel.py index 7d9d99a1..c6223b4e 100644 --- a/src/asktable/types/secure_tunnel.py +++ b/src/asktable/types/secure_tunnel.py @@ -16,6 +16,7 @@ class SecureTunnel(BaseModel): modified_at: datetime name: str + """SecureTunnel 名称,不超过 20 个字符""" project_id: str diff --git a/src/asktable/types/securetunnel_create_params.py b/src/asktable/types/securetunnel_create_params.py index 887078db..53addf73 100644 --- a/src/asktable/types/securetunnel_create_params.py +++ b/src/asktable/types/securetunnel_create_params.py @@ -2,12 +2,11 @@ from __future__ import annotations -from typing import Optional -from typing_extensions import TypedDict +from typing_extensions import Required, TypedDict __all__ = ["SecuretunnelCreateParams"] class SecuretunnelCreateParams(TypedDict, total=False): - name: Optional[str] + name: Required[str] """SecureTunnel 名称,不超过 20 个字符""" diff --git a/src/asktable/types/securetunnel_update_params.py b/src/asktable/types/securetunnel_update_params.py index 6322936a..e42566a6 100644 --- a/src/asktable/types/securetunnel_update_params.py +++ b/src/asktable/types/securetunnel_update_params.py @@ -3,17 +3,17 @@ from __future__ import annotations from typing import Optional -from typing_extensions import TypedDict +from typing_extensions import Required, TypedDict __all__ = ["SecuretunnelUpdateParams"] class SecuretunnelUpdateParams(TypedDict, total=False): + name: Required[str] + """SecureTunnel 名称,不超过 20 个字符""" + client_info: Optional[object] """客户端信息""" - name: Optional[str] - """SecureTunnel 名称,不超过 20 个字符""" - unique_key: Optional[str] """唯一标识,用于更新客户端信息(容器 ID)""" diff --git a/tests/api_resources/single_turn/test_q2a.py b/tests/api_resources/single_turn/test_q2a.py index 7ff8e41e..40bbef76 100644 --- a/tests/api_resources/single_turn/test_q2a.py +++ b/tests/api_resources/single_turn/test_q2a.py @@ -22,7 +22,7 @@ class TestQ2a: def test_method_create(self, client: Asktable) -> None: q2a = client.single_turn.q2a.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert_matches_type(Q2aResponse, q2a, path=["response"]) @@ -30,7 +30,7 @@ def test_method_create(self, client: Asktable) -> None: def test_method_create_with_all_params(self, client: Asktable) -> None: q2a = client.single_turn.q2a.create( datasource_id="datasource_id", - question="question", + question="xxx", max_rows=0, role_id="role_id", role_variables={}, @@ -42,7 +42,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: def test_raw_response_create(self, client: Asktable) -> None: response = client.single_turn.q2a.with_raw_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert response.is_closed is True @@ -54,7 +54,7 @@ def test_raw_response_create(self, client: Asktable) -> None: def test_streaming_response_create(self, client: Asktable) -> None: with client.single_turn.q2a.with_streaming_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -106,7 +106,7 @@ class TestAsyncQ2a: async def test_method_create(self, async_client: AsyncAsktable) -> None: q2a = await async_client.single_turn.q2a.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert_matches_type(Q2aResponse, q2a, path=["response"]) @@ -114,7 +114,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: q2a = await async_client.single_turn.q2a.create( datasource_id="datasource_id", - question="question", + question="xxx", max_rows=0, role_id="role_id", role_variables={}, @@ -126,7 +126,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: response = await async_client.single_turn.q2a.with_raw_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert response.is_closed is True @@ -138,7 +138,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: async with async_client.single_turn.q2a.with_streaming_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/single_turn/test_q2s.py b/tests/api_resources/single_turn/test_q2s.py index 0c792b2a..218ec4a8 100644 --- a/tests/api_resources/single_turn/test_q2s.py +++ b/tests/api_resources/single_turn/test_q2s.py @@ -22,7 +22,7 @@ class TestQ2s: def test_method_create(self, client: Asktable) -> None: q2 = client.single_turn.q2s.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert_matches_type(Q2sResponse, q2, path=["response"]) @@ -30,7 +30,7 @@ def test_method_create(self, client: Asktable) -> None: def test_method_create_with_all_params(self, client: Asktable) -> None: q2 = client.single_turn.q2s.create( datasource_id="datasource_id", - question="question", + question="xxx", role_id="role_id", role_variables={}, ) @@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: def test_raw_response_create(self, client: Asktable) -> None: response = client.single_turn.q2s.with_raw_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert response.is_closed is True @@ -52,7 +52,7 @@ def test_raw_response_create(self, client: Asktable) -> None: def test_streaming_response_create(self, client: Asktable) -> None: with client.single_turn.q2s.with_streaming_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -104,7 +104,7 @@ class TestAsyncQ2s: async def test_method_create(self, async_client: AsyncAsktable) -> None: q2 = await async_client.single_turn.q2s.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert_matches_type(Q2sResponse, q2, path=["response"]) @@ -112,7 +112,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: q2 = await async_client.single_turn.q2s.create( datasource_id="datasource_id", - question="question", + question="xxx", role_id="role_id", role_variables={}, ) @@ -122,7 +122,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: response = await async_client.single_turn.q2s.with_raw_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) assert response.is_closed is True @@ -134,7 +134,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: async with async_client.single_turn.q2s.with_streaming_response.create( datasource_id="datasource_id", - question="question", + question="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_datasources.py b/tests/api_resources/test_datasources.py index 02b182cc..ada195ef 100644 --- a/tests/api_resources/test_datasources.py +++ b/tests/api_resources/test_datasources.py @@ -36,6 +36,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: access_config={ "atst_link_id": "atst_link_123456", "db": "test", + "db_version": "5.7", "host": "192.168.0.10", "location_type": "local", "location_url": "http://example.com/data.csv", @@ -126,6 +127,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: access_config={ "atst_link_id": "atst_link_123456", "db": "test", + "db_version": "5.7", "host": "192.168.0.10", "location_type": "local", "location_url": "http://example.com/data.csv", @@ -311,6 +313,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) access_config={ "atst_link_id": "atst_link_123456", "db": "test", + "db_version": "5.7", "host": "192.168.0.10", "location_type": "local", "location_url": "http://example.com/data.csv", @@ -401,6 +404,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) access_config={ "atst_link_id": "atst_link_123456", "db": "test", + "db_version": "5.7", "host": "192.168.0.10", "location_type": "local", "location_url": "http://example.com/data.csv", diff --git a/tests/api_resources/test_securetunnels.py b/tests/api_resources/test_securetunnels.py index 896233fb..1c9f0a84 100644 --- a/tests/api_resources/test_securetunnels.py +++ b/tests/api_resources/test_securetunnels.py @@ -23,11 +23,6 @@ class TestSecuretunnels: @parametrize def test_method_create(self, client: Asktable) -> None: - securetunnel = client.securetunnels.create() - assert_matches_type(SecureTunnel, securetunnel, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Asktable) -> None: securetunnel = client.securetunnels.create( name="我的测试机", ) @@ -35,7 +30,9 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: @parametrize def test_raw_response_create(self, client: Asktable) -> None: - response = client.securetunnels.with_raw_response.create() + response = client.securetunnels.with_raw_response.create( + name="我的测试机", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -44,7 +41,9 @@ def test_raw_response_create(self, client: Asktable) -> None: @parametrize def test_streaming_response_create(self, client: Asktable) -> None: - with client.securetunnels.with_streaming_response.create() as response: + with client.securetunnels.with_streaming_response.create( + name="我的测试机", + ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -95,6 +94,7 @@ def test_path_params_retrieve(self, client: Asktable) -> None: def test_method_update(self, client: Asktable) -> None: securetunnel = client.securetunnels.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -102,8 +102,8 @@ def test_method_update(self, client: Asktable) -> None: def test_method_update_with_all_params(self, client: Asktable) -> None: securetunnel = client.securetunnels.update( securetunnel_id="securetunnel_id", - client_info={}, name="我的测试机", + client_info={}, unique_key="unique_key", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -112,6 +112,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: def test_raw_response_update(self, client: Asktable) -> None: response = client.securetunnels.with_raw_response.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) assert response.is_closed is True @@ -123,6 +124,7 @@ def test_raw_response_update(self, client: Asktable) -> None: def test_streaming_response_update(self, client: Asktable) -> None: with client.securetunnels.with_streaming_response.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -137,6 +139,7 @@ def test_path_params_update(self, client: Asktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `securetunnel_id` but received ''"): client.securetunnels.with_raw_response.update( securetunnel_id="", + name="我的测试机", ) @parametrize @@ -263,11 +266,6 @@ class TestAsyncSecuretunnels: @parametrize async def test_method_create(self, async_client: AsyncAsktable) -> None: - securetunnel = await async_client.securetunnels.create() - assert_matches_type(SecureTunnel, securetunnel, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: securetunnel = await async_client.securetunnels.create( name="我的测试机", ) @@ -275,7 +273,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) @parametrize async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: - response = await async_client.securetunnels.with_raw_response.create() + response = await async_client.securetunnels.with_raw_response.create( + name="我的测试机", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -284,7 +284,9 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: - async with async_client.securetunnels.with_streaming_response.create() as response: + async with async_client.securetunnels.with_streaming_response.create( + name="我的测试机", + ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -335,6 +337,7 @@ async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: async def test_method_update(self, async_client: AsyncAsktable) -> None: securetunnel = await async_client.securetunnels.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -342,8 +345,8 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None: async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None: securetunnel = await async_client.securetunnels.update( securetunnel_id="securetunnel_id", - client_info={}, name="我的测试机", + client_info={}, unique_key="unique_key", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -352,6 +355,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: response = await async_client.securetunnels.with_raw_response.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) assert response.is_closed is True @@ -363,6 +367,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None: async with async_client.securetunnels.with_streaming_response.update( securetunnel_id="securetunnel_id", + name="我的测试机", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -377,6 +382,7 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `securetunnel_id` but received ''"): await async_client.securetunnels.with_raw_response.update( securetunnel_id="", + name="我的测试机", ) @parametrize diff --git a/tests/test_models.py b/tests/test_models.py index 6d06ac77..bcd7fff6 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -561,6 +561,14 @@ class Model(BaseModel): m.model_dump(warnings=False) +def test_compat_method_no_error_for_warnings() -> None: + class Model(BaseModel): + foo: Optional[str] + + m = Model(foo="hello") + assert isinstance(model_dump(m, warnings=False), dict) + + def test_to_json() -> None: class Model(BaseModel): foo: Optional[str] = Field(alias="FOO", default=None)