Skip to content

Commit 521bb4a

Browse files
authored
Merge branch 'main' into chore/client-comment-fix
2 parents baa03b6 + 05810dd commit 521bb4a

File tree

22 files changed

+180
-26
lines changed

22 files changed

+180
-26
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
lint:
1313
name: lint
1414
runs-on: ubuntu-latest
15-
1615
steps:
1716
- uses: actions/checkout@v4
1817

@@ -33,7 +32,6 @@ jobs:
3332
test:
3433
name: test
3534
runs-on: ubuntu-latest
36-
3735
steps:
3836
- uses: actions/checkout@v4
3937

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.72.0"
2+
".": "1.74.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-32de3bc513663c5fac922c49be41c222b6ee8c0b841d8966bcdfa489d441daa3.yml
3-
openapi_spec_hash: ea86343b5e9858a74e85da8ab2c532f6
4-
config_hash: 43dc8df20ffec9d1503f91866cb2b7d9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a555f81249cb084f463dcefa4aba069f9341fdaf3dd6ac27d7f237fc90e8f488.yml
3+
openapi_spec_hash: 8e590296cd1a54b9508510b0c7a2c45a
4+
config_hash: 5ea32de61ff42fcf5e66cff8d9e247ea

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
# Changelog
22

3+
## 1.74.0 (2025-04-14)
4+
5+
Full Changelog: [v1.73.0...v1.74.0](https://github.com/openai/openai-python/compare/v1.73.0...v1.74.0)
6+
7+
### Features
8+
9+
* **api:** adding gpt-4.1 family of model IDs ([d4dae55](https://github.com/openai/openai-python/commit/d4dae5553ff3a2879b9ab79a6423661b212421f9))
10+
11+
12+
### Bug Fixes
13+
14+
* **chat:** skip azure async filter events ([#2255](https://github.com/openai/openai-python/issues/2255)) ([fd3a38b](https://github.com/openai/openai-python/commit/fd3a38b1ed30af0a9f3302c1cfc6be6b352e65de))
15+
16+
17+
### Chores
18+
19+
* **client:** minor internal fixes ([6071ae5](https://github.com/openai/openai-python/commit/6071ae5e8b4faa465afc8d07370737e66901900a))
20+
* **internal:** update pyright settings ([c8f8beb](https://github.com/openai/openai-python/commit/c8f8bebf852380a224701bc36826291d6387c53d))
21+
22+
## 1.73.0 (2025-04-12)
23+
24+
Full Changelog: [v1.72.0...v1.73.0](https://github.com/openai/openai-python/compare/v1.72.0...v1.73.0)
25+
26+
### Features
27+
28+
* **api:** manual updates ([a3253dd](https://github.com/openai/openai-python/commit/a3253dd798c1eccd9810d4fc593e8c2a568bcf4f))
29+
30+
31+
### Bug Fixes
32+
33+
* **perf:** optimize some hot paths ([f79d39f](https://github.com/openai/openai-python/commit/f79d39fbcaea8f366a9e48c06fb1696bab3e607d))
34+
* **perf:** skip traversing types for NotGiven values ([28d220d](https://github.com/openai/openai-python/commit/28d220de3b4a09d80450d0bcc9b347bbf68f81ec))
35+
36+
37+
### Chores
38+
39+
* **internal:** expand CI branch coverage ([#2295](https://github.com/openai/openai-python/issues/2295)) ([0ae783b](https://github.com/openai/openai-python/commit/0ae783b99122975be521365de0b6d2bce46056c9))
40+
* **internal:** reduce CI branch coverage ([2fb7d42](https://github.com/openai/openai-python/commit/2fb7d425cda679a54aa3262090479fd747363bb4))
41+
* slight wording improvement in README ([#2291](https://github.com/openai/openai-python/issues/2291)) ([e020759](https://github.com/openai/openai-python/commit/e0207598d16a2a9cb3cb3a8e8e97fa9cfdccd5e8))
42+
* workaround build errors ([4e10c96](https://github.com/openai/openai-python/commit/4e10c96a483db28dedc2d8c2908765fb7317e049))
43+
344
## 1.72.0 (2025-04-08)
445

546
Full Changelog: [v1.71.0...v1.72.0](https://github.com/openai/openai-python/compare/v1.71.0...v1.72.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ response = client.chat.responses.create(
351351

352352
## File uploads
353353

354-
Request parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
354+
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
355355

356356
```python
357357
from pathlib import Path

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai"
3-
version = "1.72.0"
3+
version = "1.74.0"
44
description = "The official Python library for the openai API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -166,6 +166,7 @@ exclude = [
166166
]
167167

168168
reportImplicitOverride = true
169+
reportOverlappingOverload = false
169170

170171
reportImportCycles = false
171172
reportPrivateUsage = false

src/openai/_base_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
411411

412412
idempotency_header = self._idempotency_header
413413
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
414-
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
414+
options.idempotency_key = options.idempotency_key or self._idempotency_key()
415+
headers[idempotency_header] = options.idempotency_key
415416

416417
# Don't set these headers if they were already set or removed by the caller. We check
417418
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
@@ -945,6 +946,10 @@ def _request(
945946
request = self._build_request(options, retries_taken=retries_taken)
946947
self._prepare_request(request)
947948

949+
if options.idempotency_key:
950+
# ensure the idempotency key is reused between requests
951+
input_options.idempotency_key = options.idempotency_key
952+
948953
kwargs: HttpxSendArgs = {}
949954
if self.custom_auth is not None:
950955
kwargs["auth"] = self.custom_auth
@@ -1492,6 +1497,10 @@ async def _request(
14921497
request = self._build_request(options, retries_taken=retries_taken)
14931498
await self._prepare_request(request)
14941499

1500+
if options.idempotency_key:
1501+
# ensure the idempotency key is reused between requests
1502+
input_options.idempotency_key = options.idempotency_key
1503+
14951504
kwargs: HttpxSendArgs = {}
14961505
if self.custom_auth is not None:
14971506
kwargs["auth"] = self.custom_auth

src/openai/_utils/_transform.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
import pathlib
66
from typing import Any, Mapping, TypeVar, cast
77
from datetime import date, datetime
8-
from typing_extensions import Literal, get_args, override, get_type_hints
8+
from typing_extensions import Literal, get_args, override, get_type_hints as _get_type_hints
99

1010
import anyio
1111
import pydantic
1212

1313
from ._utils import (
1414
is_list,
15+
is_given,
16+
lru_cache,
1517
is_mapping,
1618
is_iterable,
1719
)
@@ -108,6 +110,7 @@ class Params(TypedDict, total=False):
108110
return cast(_T, transformed)
109111

110112

113+
@lru_cache(maxsize=8096)
111114
def _get_annotated_type(type_: type) -> type | None:
112115
"""If the given type is an `Annotated` type then it is returned, if not `None` is returned.
113116
@@ -258,6 +261,11 @@ def _transform_typeddict(
258261
result: dict[str, object] = {}
259262
annotations = get_type_hints(expected_type, include_extras=True)
260263
for key, value in data.items():
264+
if not is_given(value):
265+
# we don't need to include `NotGiven` values here as they'll
266+
# be stripped out before the request is sent anyway
267+
continue
268+
261269
type_ = annotations.get(key)
262270
if type_ is None:
263271
# we do not have a type annotation for this field, leave it as is
@@ -415,10 +423,25 @@ async def _async_transform_typeddict(
415423
result: dict[str, object] = {}
416424
annotations = get_type_hints(expected_type, include_extras=True)
417425
for key, value in data.items():
426+
if not is_given(value):
427+
# we don't need to include `NotGiven` values here as they'll
428+
# be stripped out before the request is sent anyway
429+
continue
430+
418431
type_ = annotations.get(key)
419432
if type_ is None:
420433
# we do not have a type annotation for this field, leave it as is
421434
result[key] = value
422435
else:
423436
result[_maybe_transform_key(key, type_)] = await _async_transform_recursive(value, annotation=type_)
424437
return result
438+
439+
440+
@lru_cache(maxsize=8096)
441+
def get_type_hints(
442+
obj: Any,
443+
globalns: dict[str, Any] | None = None,
444+
localns: Mapping[str, Any] | None = None,
445+
include_extras: bool = False,
446+
) -> dict[str, Any]:
447+
return _get_type_hints(obj, globalns=globalns, localns=localns, include_extras=include_extras)

src/openai/_utils/_typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
get_origin,
1414
)
1515

16+
from ._utils import lru_cache
1617
from .._types import InheritsGeneric
1718
from .._compat import is_union as _is_union
1819

@@ -66,6 +67,7 @@ def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasType]:
6667

6768

6869
# Extracts T from Annotated[T, ...] or from Required[Annotated[T, ...]]
70+
@lru_cache(maxsize=8096)
6971
def strip_annotated_type(typ: type) -> type:
7072
if is_required_type(typ) or is_annotated_type(typ):
7173
return strip_annotated_type(cast(type, get_args(typ)[0]))

src/openai/_version.py

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

33
__title__ = "openai"
4-
__version__ = "1.72.0" # x-release-please-version
4+
__version__ = "1.74.0" # x-release-please-version

0 commit comments

Comments
 (0)