Skip to content

Commit cf7c292

Browse files
feat(api): api update (#18)
1 parent 84aa2d1 commit cf7c292

File tree

10 files changed

+31
-17
lines changed

10 files changed

+31
-17
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-70caff6d751e62dc360c72766ea91a07da36288a58a83a412fd64d1e8ca0aa2a.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-352b207b595dae80ace064f5b2754553010f90bbf748e6e3736324cd879341bf.yml

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ format = { chain = [
6363
"format:ruff",
6464
"format:docs",
6565
"fix:ruff",
66+
# run formatting again to fix any inconsistencies when imports are stripped
67+
"format:ruff",
6668
]}
67-
"format:black" = "black ."
6869
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
6970
"format:ruff" = "ruff format"
70-
"format:isort" = "isort ."
7171

7272
"lint" = { chain = [
7373
"check:ruff",
@@ -125,10 +125,6 @@ path = "README.md"
125125
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
126126
replacement = '[\1](https://github.com/DataMini/asktable-python/tree/main/\g<2>)'
127127

128-
[tool.black]
129-
line-length = 120
130-
target-version = ["py37"]
131-
132128
[tool.pytest.ini_options]
133129
testpaths = ["tests"]
134130
addopts = "--tb=short"

requirements-dev.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pytz==2023.3.post1
8080
# via dirty-equals
8181
respx==0.20.2
8282
rich==13.7.1
83-
ruff==0.6.5
83+
ruff==0.6.9
8484
setuptools==68.2.2
8585
# via nodeenv
8686
six==1.16.0

src/asktable/_base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ async def _request(
15751575
except Exception as err:
15761576
log.debug("Encountered Exception", exc_info=True)
15771577

1578-
if retries_taken > 0:
1578+
if remaining_retries > 0:
15791579
return await self._retry_request(
15801580
input_options,
15811581
cast_to,

src/asktable/resources/datasources/datasources.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ def update(
182182
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
183183
field_count: Optional[int] | NotGiven = NOT_GIVEN,
184184
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
185-
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
185+
meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
186+
| NotGiven = NOT_GIVEN,
186187
name: Optional[str] | NotGiven = NOT_GIVEN,
187188
sample_questions: Optional[str] | NotGiven = NOT_GIVEN,
188189
schema_count: Optional[int] | NotGiven = NOT_GIVEN,
@@ -515,7 +516,8 @@ async def update(
515516
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
516517
field_count: Optional[int] | NotGiven = NOT_GIVEN,
517518
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
518-
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
519+
meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
520+
| NotGiven = NOT_GIVEN,
519521
name: Optional[str] | NotGiven = NOT_GIVEN,
520522
sample_questions: Optional[str] | NotGiven = NOT_GIVEN,
521523
schema_count: Optional[int] | NotGiven = NOT_GIVEN,

src/asktable/types/answer_data_source_out.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33

4-
54
from .._models import BaseModel
65
from .data_source import DataSource
76
from .shared.answer_model import AnswerModel

src/asktable/types/data_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DataSource(BaseModel):
4444
engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]
4545
"""数据源引擎"""
4646

47-
meta_status: Literal["processing", "failed", "success", "unprocessed"]
47+
meta_status: Literal["processing", "failed", "warning", "success", "unprocessed"]
4848
"""元数据处理状态"""
4949

5050
project_id: str

src/asktable/types/datasource_update_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DatasourceUpdateParams(TypedDict, total=False):
1818
meta_error: Optional[str]
1919
"""元数据处理错误"""
2020

21-
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]]
21+
meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
2222
"""元数据处理状态"""
2323

2424
name: Optional[str]

tests/test_client.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import tracemalloc
1111
from typing import Any, Union, cast
1212
from unittest import mock
13+
from typing_extensions import Literal
1314

1415
import httpx
1516
import pytest
@@ -727,7 +728,14 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non
727728
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
728729
@mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
729730
@pytest.mark.respx(base_url=base_url)
730-
def test_retries_taken(self, client: Asktable, failures_before_success: int, respx_mock: MockRouter) -> None:
731+
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
732+
def test_retries_taken(
733+
self,
734+
client: Asktable,
735+
failures_before_success: int,
736+
failure_mode: Literal["status", "exception"],
737+
respx_mock: MockRouter,
738+
) -> None:
731739
client = client.with_options(max_retries=4)
732740

733741
nb_retries = 0
@@ -736,6 +744,8 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
736744
nonlocal nb_retries
737745
if nb_retries < failures_before_success:
738746
nb_retries += 1
747+
if failure_mode == "exception":
748+
raise RuntimeError("oops")
739749
return httpx.Response(500)
740750
return httpx.Response(200)
741751

@@ -1489,8 +1499,13 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter)
14891499
@mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
14901500
@pytest.mark.respx(base_url=base_url)
14911501
@pytest.mark.asyncio
1502+
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
14921503
async def test_retries_taken(
1493-
self, async_client: AsyncAsktable, failures_before_success: int, respx_mock: MockRouter
1504+
self,
1505+
async_client: AsyncAsktable,
1506+
failures_before_success: int,
1507+
failure_mode: Literal["status", "exception"],
1508+
respx_mock: MockRouter,
14941509
) -> None:
14951510
client = async_client.with_options(max_retries=4)
14961511

@@ -1500,6 +1515,8 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
15001515
nonlocal nb_retries
15011516
if nb_retries < failures_before_success:
15021517
nb_retries += 1
1518+
if failure_mode == "exception":
1519+
raise RuntimeError("oops")
15031520
return httpx.Response(500)
15041521
return httpx.Response(200)
15051522

tests/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Model(BaseModel):
245245
assert m.foo is True
246246

247247
m = Model.construct(foo="CARD_HOLDER")
248-
assert m.foo is "CARD_HOLDER"
248+
assert m.foo == "CARD_HOLDER"
249249

250250
m = Model.construct(foo={"bar": False})
251251
assert isinstance(m.foo, Submodel1)

0 commit comments

Comments
 (0)