Skip to content

Commit f48542a

Browse files
chore(api): mark some methods as deprecated
1 parent 0048a17 commit f48542a

File tree

4 files changed

+186
-132
lines changed

4 files changed

+186
-132
lines changed

src/codex/resources/projects/entries.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import typing_extensions
56
from typing import Iterable, Optional
67

78
import httpx
@@ -312,6 +313,7 @@ def publish_draft_answer(
312313
cast_to=Entry,
313314
)
314315

316+
@typing_extensions.deprecated("deprecated")
315317
def query(
316318
self,
317319
project_id: str,
@@ -707,6 +709,7 @@ async def publish_draft_answer(
707709
cast_to=Entry,
708710
)
709711

712+
@typing_extensions.deprecated("deprecated")
710713
async def query(
711714
self,
712715
project_id: str,
@@ -839,8 +842,10 @@ def __init__(self, entries: EntriesResource) -> None:
839842
self.publish_draft_answer = to_raw_response_wrapper(
840843
entries.publish_draft_answer,
841844
)
842-
self.query = to_raw_response_wrapper(
843-
entries.query,
845+
self.query = ( # pyright: ignore[reportDeprecated]
846+
to_raw_response_wrapper(
847+
entries.query # pyright: ignore[reportDeprecated],
848+
)
844849
)
845850
self.unpublish_answer = to_raw_response_wrapper(
846851
entries.unpublish_answer,
@@ -869,8 +874,10 @@ def __init__(self, entries: AsyncEntriesResource) -> None:
869874
self.publish_draft_answer = async_to_raw_response_wrapper(
870875
entries.publish_draft_answer,
871876
)
872-
self.query = async_to_raw_response_wrapper(
873-
entries.query,
877+
self.query = ( # pyright: ignore[reportDeprecated]
878+
async_to_raw_response_wrapper(
879+
entries.query # pyright: ignore[reportDeprecated],
880+
)
874881
)
875882
self.unpublish_answer = async_to_raw_response_wrapper(
876883
entries.unpublish_answer,
@@ -899,8 +906,10 @@ def __init__(self, entries: EntriesResource) -> None:
899906
self.publish_draft_answer = to_streamed_response_wrapper(
900907
entries.publish_draft_answer,
901908
)
902-
self.query = to_streamed_response_wrapper(
903-
entries.query,
909+
self.query = ( # pyright: ignore[reportDeprecated]
910+
to_streamed_response_wrapper(
911+
entries.query # pyright: ignore[reportDeprecated],
912+
)
904913
)
905914
self.unpublish_answer = to_streamed_response_wrapper(
906915
entries.unpublish_answer,
@@ -929,8 +938,10 @@ def __init__(self, entries: AsyncEntriesResource) -> None:
929938
self.publish_draft_answer = async_to_streamed_response_wrapper(
930939
entries.publish_draft_answer,
931940
)
932-
self.query = async_to_streamed_response_wrapper(
933-
entries.query,
941+
self.query = ( # pyright: ignore[reportDeprecated]
942+
async_to_streamed_response_wrapper(
943+
entries.query # pyright: ignore[reportDeprecated],
944+
)
934945
)
935946
self.unpublish_answer = async_to_streamed_response_wrapper(
936947
entries.unpublish_answer,

src/codex/resources/projects/projects.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import typing_extensions
56
from typing import Dict, List, Optional
67
from typing_extensions import Literal
78

@@ -330,6 +331,7 @@ def export(
330331
cast_to=object,
331332
)
332333

334+
@typing_extensions.deprecated("deprecated")
333335
def increment_queries(
334336
self,
335337
project_id: str,
@@ -872,6 +874,7 @@ async def export(
872874
cast_to=object,
873875
)
874876

877+
@typing_extensions.deprecated("deprecated")
875878
async def increment_queries(
876879
self,
877880
project_id: str,
@@ -1167,8 +1170,10 @@ def __init__(self, projects: ProjectsResource) -> None:
11671170
self.export = to_raw_response_wrapper(
11681171
projects.export,
11691172
)
1170-
self.increment_queries = to_raw_response_wrapper(
1171-
projects.increment_queries,
1173+
self.increment_queries = ( # pyright: ignore[reportDeprecated]
1174+
to_raw_response_wrapper(
1175+
projects.increment_queries # pyright: ignore[reportDeprecated],
1176+
)
11721177
)
11731178
self.retrieve_analytics = to_raw_response_wrapper(
11741179
projects.retrieve_analytics,
@@ -1212,8 +1217,10 @@ def __init__(self, projects: AsyncProjectsResource) -> None:
12121217
self.export = async_to_raw_response_wrapper(
12131218
projects.export,
12141219
)
1215-
self.increment_queries = async_to_raw_response_wrapper(
1216-
projects.increment_queries,
1220+
self.increment_queries = ( # pyright: ignore[reportDeprecated]
1221+
async_to_raw_response_wrapper(
1222+
projects.increment_queries # pyright: ignore[reportDeprecated],
1223+
)
12171224
)
12181225
self.retrieve_analytics = async_to_raw_response_wrapper(
12191226
projects.retrieve_analytics,
@@ -1257,8 +1264,10 @@ def __init__(self, projects: ProjectsResource) -> None:
12571264
self.export = to_streamed_response_wrapper(
12581265
projects.export,
12591266
)
1260-
self.increment_queries = to_streamed_response_wrapper(
1261-
projects.increment_queries,
1267+
self.increment_queries = ( # pyright: ignore[reportDeprecated]
1268+
to_streamed_response_wrapper(
1269+
projects.increment_queries # pyright: ignore[reportDeprecated],
1270+
)
12621271
)
12631272
self.retrieve_analytics = to_streamed_response_wrapper(
12641273
projects.retrieve_analytics,
@@ -1302,8 +1311,10 @@ def __init__(self, projects: AsyncProjectsResource) -> None:
13021311
self.export = async_to_streamed_response_wrapper(
13031312
projects.export,
13041313
)
1305-
self.increment_queries = async_to_streamed_response_wrapper(
1306-
projects.increment_queries,
1314+
self.increment_queries = ( # pyright: ignore[reportDeprecated]
1315+
async_to_streamed_response_wrapper(
1316+
projects.increment_queries # pyright: ignore[reportDeprecated],
1317+
)
13071318
)
13081319
self.retrieve_analytics = async_to_streamed_response_wrapper(
13091320
projects.retrieve_analytics,

tests/api_resources/projects/test_entries.py

Lines changed: 90 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
EntryNotifySmeResponse,
1616
)
1717

18+
# pyright: reportDeprecated=false
19+
1820
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1921

2022

@@ -382,40 +384,45 @@ def test_path_params_publish_draft_answer(self, client: Codex) -> None:
382384
@pytest.mark.skip()
383385
@parametrize
384386
def test_method_query(self, client: Codex) -> None:
385-
entry = client.projects.entries.query(
386-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
387-
question="question",
388-
)
387+
with pytest.warns(DeprecationWarning):
388+
entry = client.projects.entries.query(
389+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
390+
question="question",
391+
)
392+
389393
assert_matches_type(EntryQueryResponse, entry, path=["response"])
390394

391395
@pytest.mark.skip()
392396
@parametrize
393397
def test_method_query_with_all_params(self, client: Codex) -> None:
394-
entry = client.projects.entries.query(
395-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
396-
question="question",
397-
use_llm_matching=True,
398-
client_metadata={},
399-
query_metadata={
400-
"context": "string",
401-
"custom_metadata": {},
402-
"eval_scores": {"foo": 0},
403-
"evaluated_response": "evaluated_response",
404-
},
405-
x_client_library_version="x-client-library-version",
406-
x_integration_type="x-integration-type",
407-
x_source="x-source",
408-
x_stainless_package_version="x-stainless-package-version",
409-
)
398+
with pytest.warns(DeprecationWarning):
399+
entry = client.projects.entries.query(
400+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
401+
question="question",
402+
use_llm_matching=True,
403+
client_metadata={},
404+
query_metadata={
405+
"context": "string",
406+
"custom_metadata": {},
407+
"eval_scores": {"foo": 0},
408+
"evaluated_response": "evaluated_response",
409+
},
410+
x_client_library_version="x-client-library-version",
411+
x_integration_type="x-integration-type",
412+
x_source="x-source",
413+
x_stainless_package_version="x-stainless-package-version",
414+
)
415+
410416
assert_matches_type(EntryQueryResponse, entry, path=["response"])
411417

412418
@pytest.mark.skip()
413419
@parametrize
414420
def test_raw_response_query(self, client: Codex) -> None:
415-
response = client.projects.entries.with_raw_response.query(
416-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
417-
question="question",
418-
)
421+
with pytest.warns(DeprecationWarning):
422+
response = client.projects.entries.with_raw_response.query(
423+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
424+
question="question",
425+
)
419426

420427
assert response.is_closed is True
421428
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -425,26 +432,28 @@ def test_raw_response_query(self, client: Codex) -> None:
425432
@pytest.mark.skip()
426433
@parametrize
427434
def test_streaming_response_query(self, client: Codex) -> None:
428-
with client.projects.entries.with_streaming_response.query(
429-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
430-
question="question",
431-
) as response:
432-
assert not response.is_closed
433-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
435+
with pytest.warns(DeprecationWarning):
436+
with client.projects.entries.with_streaming_response.query(
437+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
438+
question="question",
439+
) as response:
440+
assert not response.is_closed
441+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
434442

435-
entry = response.parse()
436-
assert_matches_type(EntryQueryResponse, entry, path=["response"])
443+
entry = response.parse()
444+
assert_matches_type(EntryQueryResponse, entry, path=["response"])
437445

438446
assert cast(Any, response.is_closed) is True
439447

440448
@pytest.mark.skip()
441449
@parametrize
442450
def test_path_params_query(self, client: Codex) -> None:
443-
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
444-
client.projects.entries.with_raw_response.query(
445-
project_id="",
446-
question="question",
447-
)
451+
with pytest.warns(DeprecationWarning):
452+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
453+
client.projects.entries.with_raw_response.query(
454+
project_id="",
455+
question="question",
456+
)
448457

449458
@pytest.mark.skip()
450459
@parametrize
@@ -863,40 +872,45 @@ async def test_path_params_publish_draft_answer(self, async_client: AsyncCodex)
863872
@pytest.mark.skip()
864873
@parametrize
865874
async def test_method_query(self, async_client: AsyncCodex) -> None:
866-
entry = await async_client.projects.entries.query(
867-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
868-
question="question",
869-
)
875+
with pytest.warns(DeprecationWarning):
876+
entry = await async_client.projects.entries.query(
877+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
878+
question="question",
879+
)
880+
870881
assert_matches_type(EntryQueryResponse, entry, path=["response"])
871882

872883
@pytest.mark.skip()
873884
@parametrize
874885
async def test_method_query_with_all_params(self, async_client: AsyncCodex) -> None:
875-
entry = await async_client.projects.entries.query(
876-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
877-
question="question",
878-
use_llm_matching=True,
879-
client_metadata={},
880-
query_metadata={
881-
"context": "string",
882-
"custom_metadata": {},
883-
"eval_scores": {"foo": 0},
884-
"evaluated_response": "evaluated_response",
885-
},
886-
x_client_library_version="x-client-library-version",
887-
x_integration_type="x-integration-type",
888-
x_source="x-source",
889-
x_stainless_package_version="x-stainless-package-version",
890-
)
886+
with pytest.warns(DeprecationWarning):
887+
entry = await async_client.projects.entries.query(
888+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
889+
question="question",
890+
use_llm_matching=True,
891+
client_metadata={},
892+
query_metadata={
893+
"context": "string",
894+
"custom_metadata": {},
895+
"eval_scores": {"foo": 0},
896+
"evaluated_response": "evaluated_response",
897+
},
898+
x_client_library_version="x-client-library-version",
899+
x_integration_type="x-integration-type",
900+
x_source="x-source",
901+
x_stainless_package_version="x-stainless-package-version",
902+
)
903+
891904
assert_matches_type(EntryQueryResponse, entry, path=["response"])
892905

893906
@pytest.mark.skip()
894907
@parametrize
895908
async def test_raw_response_query(self, async_client: AsyncCodex) -> None:
896-
response = await async_client.projects.entries.with_raw_response.query(
897-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
898-
question="question",
899-
)
909+
with pytest.warns(DeprecationWarning):
910+
response = await async_client.projects.entries.with_raw_response.query(
911+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
912+
question="question",
913+
)
900914

901915
assert response.is_closed is True
902916
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -906,26 +920,28 @@ async def test_raw_response_query(self, async_client: AsyncCodex) -> None:
906920
@pytest.mark.skip()
907921
@parametrize
908922
async def test_streaming_response_query(self, async_client: AsyncCodex) -> None:
909-
async with async_client.projects.entries.with_streaming_response.query(
910-
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
911-
question="question",
912-
) as response:
913-
assert not response.is_closed
914-
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
923+
with pytest.warns(DeprecationWarning):
924+
async with async_client.projects.entries.with_streaming_response.query(
925+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
926+
question="question",
927+
) as response:
928+
assert not response.is_closed
929+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
915930

916-
entry = await response.parse()
917-
assert_matches_type(EntryQueryResponse, entry, path=["response"])
931+
entry = await response.parse()
932+
assert_matches_type(EntryQueryResponse, entry, path=["response"])
918933

919934
assert cast(Any, response.is_closed) is True
920935

921936
@pytest.mark.skip()
922937
@parametrize
923938
async def test_path_params_query(self, async_client: AsyncCodex) -> None:
924-
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
925-
await async_client.projects.entries.with_raw_response.query(
926-
project_id="",
927-
question="question",
928-
)
939+
with pytest.warns(DeprecationWarning):
940+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
941+
await async_client.projects.entries.with_raw_response.query(
942+
project_id="",
943+
question="question",
944+
)
929945

930946
@pytest.mark.skip()
931947
@parametrize

0 commit comments

Comments
 (0)